annotate tests/testdisp.c @ 662:2e94ef0515d7 1.1.0-rc1

Updated copyright information
author Sebastien Decugis <sdecugis@nict.go.jp>
date Fri, 14 Jan 2011 16:27:21 +0900
parents f198d16fa7f4
children 4ffbc9f1e922
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
662
2e94ef0515d7 Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
5 * Copyright (c) 2011, WIDE Project and NICT *
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 #include "tests.h"
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
38 #define Define_cb( __int, __extra ) \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
39 int cb_##__int( struct msg ** msg, struct avp * avp, struct session * session, void * opaque, enum disp_action * action ) \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
40 { \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
41 CHECK( 1, msg ? 1 : 0 ); \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
42 CHECK( 1, action ? 1 : 0 ); \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
43 CHECK( sess, session ); \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
44 if (opaque) { \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
45 CHECK( 1, opaque == g_opaque ? 1 : 0 ); \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
46 } \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
47 *action = DISP_ACT_CONT; \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
48 cbcalled[__int] += 1; \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
49 do { \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
50 __extra ; \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
51 } while (0); \
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
52 return 0; \
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 #define NB_CB 10
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56 char cbcalled[NB_CB];
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 struct session * sess;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
58 void * g_opaque = (void *)"test";
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60 /* cb_0 */ Define_cb( 0, );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
61 /* cb_1 */ Define_cb( 1, );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 /* cb_2 */ Define_cb( 2, );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
63 /* cb_3 */ Define_cb( 3, );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64 /* cb_4 */ Define_cb( 4, );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
65 /* cb_5 */ Define_cb( 5, );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66 /* cb_6 */ Define_cb( 6, return 12345 );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
67 /* cb_7 */ Define_cb( 7, { CHECK( 1, avp ? 1 : 0 ); } );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
68 /* cb_8 */ Define_cb( 8, { CHECK( 0, fd_msg_free( *msg ) ); *msg = NULL; } );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
69 /* cb_9 */ Define_cb( 9, *action = DISP_ACT_SEND );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
70 /* max: cb_<NB_CB - 1> */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
71
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
72 /* Create a new message containing what we want */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
73 struct msg * new_msg(int appid, struct dict_object * cmd, struct dict_object * avp1, struct dict_object * avp2, int val)
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
74 {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
75 struct msg *new;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
76 struct avp *avp;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
77 union avp_value value;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
78 struct msg_hdr * msg_hdr = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
79
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
80 CHECK( 0, fd_msg_new ( cmd, 0, &new ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
81 CHECK( 0, fd_msg_hdr ( new, &msg_hdr ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
82 msg_hdr->msg_appl = appid;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
83
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
84 if (avp1) {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
85 CHECK( 0, fd_msg_avp_new ( avp1, 0, &avp ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
86 value.u32 = 0;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
87 CHECK( 0, fd_msg_avp_setvalue ( avp, &value ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88 CHECK( 0, fd_msg_avp_add ( new, MSG_BRW_LAST_CHILD, avp ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
89 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91 if (avp2) {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
92 CHECK( 0, fd_msg_avp_new ( avp2, 0, &avp ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
93 value.u32 = val;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
94 CHECK( 0, fd_msg_avp_setvalue ( avp, &value ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
95 CHECK( 0, fd_msg_avp_add ( new, MSG_BRW_LAST_CHILD, avp ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
96 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
97
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
98 return new;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
99 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
100
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
101 /* Main test routine */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
102 int main(int argc, char *argv[])
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
103 {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
104 struct dict_object * app1, * app2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
105 struct dict_object * cmd1, * cmd2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
106 struct dict_object * avp1, * avp2; /* avp2 is enumerated; they are both unsigned32 types */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
107 struct dict_object * enu1, * enu2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
108 struct msg * msg = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
109 enum disp_action action;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
110 struct disp_hdl * hdl[NB_CB];
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
111 struct disp_when when;
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
112 const char * ec;
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
113
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
114 /* First, initialize the daemon modules */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
115 INIT_FD();
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
116
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
117 /* Create a dummy session, we don't use it anyway */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
118 CHECK( 0, fd_sess_new( &sess, "test.disp", NULL, 0 ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
119
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
120 memset(&when, 0xff, sizeof(when)); /* check that we don't use un-initialized parts */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
121
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
122 /* Initialize dictionary objects */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
123 {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
124 struct dict_object * enutype;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125 struct dict_application_data app1_data = { 1, "Application test 1" };
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
126 struct dict_application_data app2_data = { 2, "Application test 2" };
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
127 struct dict_cmd_data cmd1_data = { 1, "Command test 1 (req)", CMD_FLAG_REQUEST, CMD_FLAG_REQUEST };
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
128 struct dict_cmd_data cmd2_data = { 1, "Command test 2 (ans)", CMD_FLAG_REQUEST, 0 };
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
129 struct dict_type_data type_data = { AVP_TYPE_UNSIGNED32, "Type test", NULL, NULL };
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
130 struct dict_avp_data avp1_data = { 10001, 0, "AVP test 1", 0, 0, AVP_TYPE_UNSIGNED32 };
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
131 struct dict_avp_data avp2_data = { 10002, 0, "AVP test 2", 0, 0, AVP_TYPE_UNSIGNED32 };
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
132 struct dict_enumval_data enu1_data = { "ENU test 1", { .u32 = 1 }};
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
133 struct dict_enumval_data enu2_data = { "ENU test 2", { .u32 = 2 }};
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134
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_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app1_data, NULL, &app1 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
136 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app2_data, NULL, &app2 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
137 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd1_data, NULL, &cmd1 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
138 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd2_data, NULL, &cmd2 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
139 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data, NULL, &enutype ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
140 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp1_data, NULL, &avp1 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
141 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp2_data, enutype, &avp2 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
142 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &enu1_data, enutype, &enu1 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
143 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &enu2_data, enutype, &enu2 ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
144 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
145
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146 /* Register first handler, very simple test */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
147 {
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
148 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, NULL, NULL, &hdl[0] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
149 CHECK( 1, hdl[0] ? 1 : 0 );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
150 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151 CHECK( NULL, hdl[0] );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
152 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, NULL, NULL, &hdl[0] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 /* Check this handler is called for a message */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155 msg = new_msg( 0, cmd1, avp1, NULL, 0 );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156 memset(cbcalled, 0, sizeof(cbcalled));
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
157 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
158 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
159 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
160
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
161 /* Delete the message */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
162 CHECK( 0, fd_msg_free( msg ) );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
163 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
164 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166 /* Handlers for applications */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
167 {
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
168 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, &when, NULL, &hdl[0] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169 when.app = app1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
170 CHECK( 0, fd_disp_register( cb_1, DISP_HOW_APPID, &when, NULL, &hdl[1] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
171 when.app = app2;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
172 CHECK( 0, fd_disp_register( cb_2, DISP_HOW_APPID, &when, NULL, &hdl[2] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173 when.avp = avp2;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
174 CHECK( 0, fd_disp_register( cb_3, DISP_HOW_APPID, &when, NULL, &hdl[3] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
175 when.avp = avp1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
176 CHECK( 0, fd_disp_register( cb_4, DISP_HOW_APPID, &when, NULL, &hdl[4] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
177
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
178 /* Check the callbacks are called as appropriate */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
179 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
180 msg = new_msg( 0, cmd1, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
181 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
182 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
183 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
184 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
185 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
186 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
187 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
188 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
189
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
190 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
191 msg = new_msg( 1, cmd1, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
192 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
193 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
194 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
195 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
196 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
197 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
198 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
199 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
200
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
201 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
202 msg = new_msg( 2, cmd1, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
203 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
204 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
205 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
206 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
207 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
208 CHECK( 1, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
209 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
210 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
211
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
212 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
213 CHECK( 0, fd_disp_unregister( &hdl[1], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
214 CHECK( 0, fd_disp_unregister( &hdl[2], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
215 CHECK( 0, fd_disp_unregister( &hdl[3], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
216 CHECK( 0, fd_disp_unregister( &hdl[4], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
217 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
218
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
219 /* Handlers for commands */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
220 {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
221 when.app = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
222 when.command = NULL;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
223 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, &when, NULL, &hdl[0] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
224 CHECK( EINVAL, fd_disp_register( cb_1, DISP_HOW_CC, &when, NULL, &hdl[1] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
225 when.command = cmd1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
226 CHECK( 0, fd_disp_register( cb_1, DISP_HOW_CC, &when, NULL, &hdl[1] ) ); /* cmd1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
227 when.app = app2;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
228 CHECK( 0, fd_disp_register( cb_2, DISP_HOW_CC, &when, NULL, &hdl[2] ) ); /* app2 + cmd1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
229 when.command = cmd2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
230 when.app = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
231 when.avp = avp1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
232 CHECK( 0, fd_disp_register( cb_3, DISP_HOW_CC, &when, NULL, &hdl[3] ) ); /* cmd2 (avp1 ignored) */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
233
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
234 /* Check the callbacks are called as appropriate */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
235 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
236 msg = new_msg( 0, cmd1, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
237 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
238 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
239 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
240 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
241 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
242 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
243 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
244
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
245 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
246 msg = new_msg( 2, cmd1, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
247 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
248 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
249 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
250 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
251 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
252 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
253 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
254
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
255 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
256 msg = new_msg( 2, cmd2, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
257 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
258 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
259 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
260 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
261 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
262 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
263 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
264
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
265 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
266 msg = new_msg( 1, cmd2, NULL, avp2, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
267 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
268 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
269 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
270 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
271 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
272 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
273 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
274
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
275 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
276 CHECK( 0, fd_disp_unregister( &hdl[1], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
277 CHECK( 0, fd_disp_unregister( &hdl[2], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
278 CHECK( 0, fd_disp_unregister( &hdl[3], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
279 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
280
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
281 /* Handlers for AVPs */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
282 {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
283 when.app = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
284 when.command = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
285 when.avp = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
286
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
287 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, &when, NULL, &hdl[0] ) ); /* all */
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
288 CHECK( EINVAL, fd_disp_register( cb_1, DISP_HOW_AVP, &when, NULL, &hdl[1] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
289
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
290 when.avp = avp1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
291 CHECK( 0, fd_disp_register( cb_1, DISP_HOW_AVP, &when, NULL, &hdl[1] ) ); /* avp1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
292
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
293 when.command = cmd1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
294 CHECK( 0, fd_disp_register( cb_2, DISP_HOW_AVP, &when, NULL, &hdl[2] ) ); /* avp1 + cmd1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
295
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
296 when.command = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
297 when.app = app1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
298 CHECK( 0, fd_disp_register( cb_3, DISP_HOW_AVP, &when, NULL, &hdl[3] ) ); /* avp1 + app1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
299
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
300 when.command = cmd1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
301 CHECK( 0, fd_disp_register( cb_4, DISP_HOW_AVP, &when, NULL, &hdl[4] ) ); /* avp1 + cmd1 + app1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
302
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
303 when.app = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
304 when.command = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
305 when.avp = avp2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
306 when.value = enu1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
307 CHECK( 0, fd_disp_register( cb_5, DISP_HOW_AVP, &when, NULL, &hdl[5] ) ); /* avp2 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
308
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
309 when.value = enu2;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
310 CHECK( 0, fd_disp_register( cb_7, DISP_HOW_AVP, &when, NULL, &hdl[6] ) ); /* avp2 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
311
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
312
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
313
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
314 /* Check the callbacks are called as appropriate */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
315 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
316 msg = new_msg( 0, cmd1, NULL, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
317 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
318 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
319 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
320 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
321 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
322 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
323 CHECK( 0, cbcalled[5] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
324 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
325 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
326
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
327 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
328 msg = new_msg( 0, cmd1, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
329 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
330 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
331 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
332 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
333 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
334 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
335 CHECK( 0, cbcalled[5] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
336 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
337 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
338
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
339 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
340 msg = new_msg( 1, cmd2, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
341 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
342 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
343 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
344 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
345 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
346 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
347 CHECK( 0, cbcalled[5] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
348 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
349 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
350
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
351 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
352 msg = new_msg( 1, cmd1, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
353 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
354 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
355 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
356 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
357 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
358 CHECK( 1, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
359 CHECK( 0, cbcalled[5] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
360 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
361 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
362
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
363 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
364 msg = new_msg( 1, cmd1, avp1, avp2, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
365 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
366 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
367 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
368 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
369 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
370 CHECK( 1, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
371 CHECK( 1, cbcalled[5] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
372 CHECK( 1, cbcalled[7] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
373 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
374 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
375
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
376 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
377 msg = new_msg( 1, cmd1, NULL, avp2, 1 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
378 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
379 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
380 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
381 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
382 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
383 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
384 CHECK( 1, cbcalled[5] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
385 CHECK( 1, cbcalled[7] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
386 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
387 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
388
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
389 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
390 msg = new_msg( 1, cmd1, NULL, avp2, 2 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
391 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
392 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
393 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
394 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
395 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
396 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
397 CHECK( 1, cbcalled[5] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
398 CHECK( 1, cbcalled[7] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
399 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
400 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
401
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
402 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
403 CHECK( 0, fd_disp_unregister( &hdl[1], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
404 CHECK( 0, fd_disp_unregister( &hdl[2], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
405 CHECK( 0, fd_disp_unregister( &hdl[3], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
406 CHECK( 0, fd_disp_unregister( &hdl[4], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
407 CHECK( 0, fd_disp_unregister( &hdl[5], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
408 CHECK( 0, fd_disp_unregister( &hdl[6], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
409 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
410
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
411 /* Handlers for enum values */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
412 {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
413 when.app = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
414 when.command = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
415 when.avp = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
416 when.value = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
417
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
418 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, &when, NULL, &hdl[0] ) ); /* all */
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
419 CHECK( EINVAL, fd_disp_register( cb_1, DISP_HOW_AVP_ENUMVAL, &when, NULL, &hdl[1] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
420 when.value = enu1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
421 CHECK( EINVAL, fd_disp_register( cb_1, DISP_HOW_AVP_ENUMVAL, &when, NULL, &hdl[1] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
422 when.avp = avp1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
423 CHECK( EINVAL, fd_disp_register( cb_1, DISP_HOW_AVP_ENUMVAL, &when, NULL, &hdl[1] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
424 when.avp = avp2;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
425 CHECK( 0, fd_disp_register( cb_1, DISP_HOW_AVP_ENUMVAL, &when, NULL, &hdl[1] ) ); /* avp2, enu1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
426
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
427 when.command = cmd1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
428 CHECK( 0, fd_disp_register( cb_2, DISP_HOW_AVP_ENUMVAL, &when, NULL, &hdl[2] ) ); /* avp2, enu1 + cmd1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
429
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
430 when.command = NULL;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
431 when.app = app1;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
432 when.value = enu2;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
433 CHECK( 0, fd_disp_register( cb_3, DISP_HOW_AVP_ENUMVAL, &when, NULL, &hdl[3] ) ); /* avp2, enu2 + app1 */
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
434
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
435 /* Check the callbacks are called as appropriate */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
436 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
437 msg = new_msg( 0, cmd1, avp1, NULL, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
438 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
439 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
440 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
441 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
442 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
443 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
444 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
445
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
446 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
447 msg = new_msg( 1, cmd2, avp1, avp2, 0 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
448 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
449 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
450 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
451 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
452 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
453 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
454 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
455
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
456 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
457 msg = new_msg( 1, cmd2, avp1, avp2, 1 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
458 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
459 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
460 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
461 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
462 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
463 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
464 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
465
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
466 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
467 msg = new_msg( 1, cmd2, avp1, avp2, 2 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
468 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
469 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
470 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
471 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
472 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
473 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
474 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
475
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
476 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
477 msg = new_msg( 1, cmd1, avp1, avp2, 1 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
478 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
479 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
480 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
481 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
482 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
483 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
484 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
485
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
486 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
487 msg = new_msg( 1, cmd2, avp1, avp2, 1 );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
488 {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
489 struct avp *avp;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
490 union avp_value value;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
491 CHECK( 0, fd_msg_avp_new ( avp2, 0, &avp ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
492 value.u32 = 2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
493 CHECK( 0, fd_msg_avp_setvalue ( avp, &value ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
494 CHECK( 0, fd_msg_avp_add ( msg, MSG_BRW_LAST_CHILD, avp ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
495 }
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
496 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
497 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
498 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
499 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
500 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
501 CHECK( DISP_ACT_CONT, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
502 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
503
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
504 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
505 CHECK( 0, fd_disp_unregister( &hdl[1], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
506 CHECK( 0, fd_disp_unregister( &hdl[2], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
507 CHECK( 0, fd_disp_unregister( &hdl[3], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
508 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
509
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
510 /* Test behavior of handlers */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
511 {
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
512 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, &when, NULL, &hdl[0] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
513 CHECK( 0, fd_disp_register( cb_1, DISP_HOW_ANY, &when, NULL, &hdl[1] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
514 CHECK( 0, fd_disp_register( cb_6, DISP_HOW_ANY, &when, NULL, &hdl[2] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
515 CHECK( 0, fd_disp_register( cb_2, DISP_HOW_ANY, &when, NULL, &hdl[3] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
516 CHECK( 0, fd_disp_register( cb_3, DISP_HOW_ANY, &when, NULL, &hdl[4] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
517
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
518 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
519 msg = new_msg( 1, cmd1, avp1, avp2, 1 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
520 CHECK( 12345, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
521 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
522 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
523 CHECK( 1, cbcalled[6] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
524 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
525 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
526 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
527
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
528 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
529 CHECK( 0, fd_disp_unregister( &hdl[1], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
530 CHECK( 0, fd_disp_unregister( &hdl[2], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
531 CHECK( 0, fd_disp_unregister( &hdl[3], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
532 CHECK( 0, fd_disp_unregister( &hdl[4], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
533
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
534 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, &when, NULL, &hdl[0] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
535 CHECK( 0, fd_disp_register( cb_1, DISP_HOW_ANY, &when, NULL, &hdl[1] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
536 CHECK( 0, fd_disp_register( cb_8, DISP_HOW_ANY, &when, NULL, &hdl[2] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
537 CHECK( 0, fd_disp_register( cb_2, DISP_HOW_ANY, &when, NULL, &hdl[3] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
538 CHECK( 0, fd_disp_register( cb_3, DISP_HOW_ANY, &when, NULL, &hdl[4] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
539
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
540 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
541 msg = new_msg( 1, cmd1, avp1, avp2, 1 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
542 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
543 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
544 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
545 CHECK( 1, cbcalled[8] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
546 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
547 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
548 CHECK( NULL, msg );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
549
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
550 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
551 CHECK( 0, fd_disp_unregister( &hdl[1], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
552 CHECK( 0, fd_disp_unregister( &hdl[2], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
553 CHECK( 0, fd_disp_unregister( &hdl[3], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
554 CHECK( 0, fd_disp_unregister( &hdl[4], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
555
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
556 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, &when, NULL, &hdl[0] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
557 CHECK( 0, fd_disp_register( cb_1, DISP_HOW_ANY, &when, NULL, &hdl[1] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
558 CHECK( 0, fd_disp_register( cb_9, DISP_HOW_ANY, &when, NULL, &hdl[2] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
559 CHECK( 0, fd_disp_register( cb_2, DISP_HOW_ANY, &when, NULL, &hdl[3] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
560 CHECK( 0, fd_disp_register( cb_3, DISP_HOW_ANY, &when, NULL, &hdl[4] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
561
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
562 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
563 msg = new_msg( 1, cmd1, avp1, avp2, 1 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
564 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
565 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
566 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
567 CHECK( 1, cbcalled[9] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
568 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
569 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
570 CHECK( DISP_ACT_SEND, action );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
571 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
572
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
573 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
574 CHECK( 0, fd_disp_unregister( &hdl[1], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
575 CHECK( 0, fd_disp_unregister( &hdl[2], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
576 CHECK( 0, fd_disp_unregister( &hdl[3], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
577 CHECK( 0, fd_disp_unregister( &hdl[4], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
578 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
579
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
580 /* Test order of handlers */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
581 {
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
582 when.app = app2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
583 when.command = cmd2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
584 when.avp = avp2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
585 when.value = enu2;
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
586
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
587 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, &when, NULL, &hdl[0] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
588 CHECK( 0, fd_disp_register( cb_1, DISP_HOW_AVP_ENUMVAL, &when, NULL, &hdl[1] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
589 CHECK( 0, fd_disp_register( cb_2, DISP_HOW_AVP, &when, NULL, &hdl[2] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
590 CHECK( 0, fd_disp_register( cb_3, DISP_HOW_CC, &when, NULL, &hdl[3] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
591 CHECK( 0, fd_disp_register( cb_4, DISP_HOW_APPID, &when, NULL, &hdl[4] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
592
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
593 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
594 msg = new_msg( 2, cmd2, avp1, avp2, 2 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
595 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
596 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
597 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
598 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
599 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
600 CHECK( 1, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
601 CHECK( 0, cbcalled[9] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
602 CHECK( 0, fd_msg_free( msg ) );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
603
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
604 CHECK( 0, fd_disp_register( cb_9, DISP_HOW_ANY, &when, NULL, &hdl[5] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
605 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
606 msg = new_msg( 2, cmd2, avp1, avp2, 2 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
607 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
608 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
609 CHECK( 0, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
610 CHECK( 0, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
611 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
612 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
613 CHECK( 1, cbcalled[9] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
614 CHECK( 0, fd_msg_free( msg ) );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
615 CHECK( 0, fd_disp_unregister( &hdl[5], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
616
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
617 CHECK( 0, fd_disp_register( cb_9, DISP_HOW_AVP_ENUMVAL, &when, NULL, &hdl[5] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
618 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
619 msg = new_msg( 2, cmd2, avp1, avp2, 2 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
620 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
621 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
622 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
623 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
624 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
625 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
626 CHECK( 1, cbcalled[9] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
627 CHECK( 0, fd_msg_free( msg ) );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
628 CHECK( 0, fd_disp_unregister( &hdl[5], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
629
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
630 CHECK( 0, fd_disp_register( cb_9, DISP_HOW_AVP, &when, NULL, &hdl[5] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
631 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
632 msg = new_msg( 2, cmd2, avp1, avp2, 2 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
633 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
634 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
635 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
636 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
637 CHECK( 0, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
638 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
639 CHECK( 1, cbcalled[9] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
640 CHECK( 0, fd_msg_free( msg ) );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
641 CHECK( 0, fd_disp_unregister( &hdl[5], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
642
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
643 CHECK( 0, fd_disp_register( cb_9, DISP_HOW_CC, &when, NULL, &hdl[5] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
644 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
645 msg = new_msg( 2, cmd2, avp1, avp2, 2 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
646 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
647 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
648 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
649 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
650 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
651 CHECK( 0, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
652 CHECK( 1, cbcalled[9] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
653 CHECK( 0, fd_msg_free( msg ) );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
654 CHECK( 0, fd_disp_unregister( &hdl[5], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
655
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
656 CHECK( 0, fd_disp_register( cb_9, DISP_HOW_APPID, &when, NULL, &hdl[5] ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
657 memset(cbcalled, 0, sizeof(cbcalled));
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
658 msg = new_msg( 2, cmd2, avp1, avp2, 2 );
90
2c9444152e4b Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
659 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
660 CHECK( 1, cbcalled[0] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
661 CHECK( 1, cbcalled[1] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
662 CHECK( 1, cbcalled[2] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
663 CHECK( 1, cbcalled[3] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
664 CHECK( 1, cbcalled[4] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
665 CHECK( 1, cbcalled[9] );
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
666 CHECK( 0, fd_msg_free( msg ) );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
667 CHECK( 0, fd_disp_unregister( &hdl[5], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
668
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
669 CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
670 CHECK( 0, fd_disp_unregister( &hdl[1], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
671 CHECK( 0, fd_disp_unregister( &hdl[2], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
672 CHECK( 0, fd_disp_unregister( &hdl[3], NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
673 CHECK( 0, fd_disp_unregister( &hdl[4], NULL ) );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
674 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
675
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
676 /* Test application support advertisement */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
677 {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
678 struct dict_object * vnd;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
679 struct dict_vendor_data vnd_data = { 1, "Vendor test" };
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
680 struct fd_app * app;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
681
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
682 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_VENDOR, &vnd_data, NULL, &vnd ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
683
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
684 CHECK( EINVAL, fd_disp_app_support ( vnd, NULL, 1, 0 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
685 CHECK( EINVAL, fd_disp_app_support ( app1, NULL, 0, 0 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
686 CHECK( 0, fd_disp_app_support ( app1, NULL, 1, 0 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
687 CHECK( 0, fd_disp_app_support ( app1, NULL, 0, 1 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
688 CHECK( 0, fd_disp_app_support ( app2, vnd, 1, 0 ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
689
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
690 app = (struct fd_app *)(fd_g_config->cnf_apps.next);
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
691 CHECK( 1, app->appid );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
692 CHECK( 1, app->flags.auth );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
693 CHECK( 1, app->flags.acct );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
694 app = (struct fd_app *)(fd_g_config->cnf_apps.prev);
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
695 CHECK( 2, app->appid );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
696 CHECK( 1, app->flags.auth );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
697 CHECK( 0, app->flags.acct );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
698
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
699 #if 0
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
700 fd_conf_dump();
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
701 #endif
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
702 }
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
703
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
704 /* Test opaque pointer management */
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
705 {
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
706 void * ptr;
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
707 CHECK( 0, fd_disp_register( cb_0, DISP_HOW_ANY, NULL, g_opaque, &hdl[0] ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
708
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
709 /* Check this handler is called for a message */
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
710 msg = new_msg( 0, cmd1, avp1, NULL, 0 );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
711 memset(cbcalled, 0, sizeof(cbcalled));
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
712 CHECK( 0, fd_msg_dispatch ( &msg, sess, &action, &ec ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
713 CHECK( 1, cbcalled[0] );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
714 CHECK( DISP_ACT_CONT, action );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
715
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
716 /* Delete the message */
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
717 CHECK( 0, fd_msg_free( msg ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
718 CHECK( 0, fd_disp_unregister( &hdl[0], &ptr ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
719 CHECK( 1, ptr == g_opaque ? 1 : 0 );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
720 }
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 90
diff changeset
721
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
722 /* That's all for the tests yet */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
723 PASSTEST();
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
724 }
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
725
"Welcome to our mercurial repository"