1 | /********************************************************************************************************* |
---|
2 | * Software License Agreement (BSD License) * |
---|
3 | * Author: Alexandre Westfahl <awestfahl@freediameter.net> * |
---|
4 | * * |
---|
5 | * Copyright (c) 2010, Alexandre Westfahl, Teraoka Laboratory (Keio University), and the WIDE Project. * |
---|
6 | * * |
---|
7 | * All rights reserved. * |
---|
8 | * * |
---|
9 | * Redistribution and use of this software in source and binary forms, with or without modification, are * |
---|
10 | * permitted provided that the following conditions are met: * |
---|
11 | * * |
---|
12 | * * Redistributions of source code must retain the above * |
---|
13 | * copyright notice, this list of conditions and the * |
---|
14 | * following disclaimer. * |
---|
15 | * * |
---|
16 | * * Redistributions in binary form must reproduce the above * |
---|
17 | * copyright notice, this list of conditions and the * |
---|
18 | * following disclaimer in the documentation and/or other * |
---|
19 | * materials provided with the distribution. * |
---|
20 | * * |
---|
21 | * * Neither the name of the Teraoka Laboratory nor the * |
---|
22 | * names of its contributors may be used to endorse or * |
---|
23 | * promote products derived from this software without * |
---|
24 | * specific prior written permission of Teraoka Laboratory * |
---|
25 | * * |
---|
26 | * * |
---|
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * |
---|
28 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
---|
29 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
---|
30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
---|
31 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
---|
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
---|
33 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
---|
34 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
---|
35 | *********************************************************************************************************/ |
---|
36 | #include "test_sip.h" |
---|
37 | |
---|
38 | //Called to send a UAR |
---|
39 | int test_sip_SAR_cb() |
---|
40 | { |
---|
41 | struct dict_object * sar_model=NULL; |
---|
42 | struct msg * message=NULL; |
---|
43 | struct avp *avp=NULL; |
---|
44 | struct session *sess=NULL; |
---|
45 | union avp_value value; |
---|
46 | |
---|
47 | //Fake values START |
---|
48 | char *sip_aor="sip:aw-lappy@tera.ics.keio.ac.jp"; |
---|
49 | size_t aor_len=strlen(sip_aor); |
---|
50 | char *destination_realm="tera.ics.keio.ac.jp"; |
---|
51 | size_t destination_realmlen=strlen(destination_realm); |
---|
52 | char *destination_host="suika.tera.ics.keio.ac.jp"; |
---|
53 | size_t destination_hostlen=strlen(destination_host); |
---|
54 | char *username="aw-lappy"; |
---|
55 | size_t usernamelen=strlen(username); |
---|
56 | char *sipserveruri="sip:ichigo@tera.ics.keio.ac.jp"; |
---|
57 | size_t sipserverurilen=strlen(sipserveruri); |
---|
58 | // char *visitednetwork="Pink"; |
---|
59 | //size_t visitednetworklen=strlen(visitednetwork); |
---|
60 | //int registrationtype = 2; |
---|
61 | int data_already_available=0; |
---|
62 | int assignment_type=0; |
---|
63 | //Fake values STOP |
---|
64 | |
---|
65 | //Create the base message for an RTR |
---|
66 | CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Server-Assignment-Request", &sar_model, ENOENT) ); |
---|
67 | CHECK_FCT( fd_msg_new (sar_model, 0, &message)); |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | // Create a new session |
---|
72 | { |
---|
73 | CHECK_FCT( fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, (os0_t)"appsip", 6 )); |
---|
74 | os0_t sid; |
---|
75 | size_t sidlen; |
---|
76 | CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen )); |
---|
77 | CHECK_FCT( fd_msg_avp_new ( sip_dict.Session_Id, 0, &avp )); |
---|
78 | value.os.data = sid; |
---|
79 | value.os.len = sidlen; |
---|
80 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value )); |
---|
81 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_FIRST_CHILD, avp )); |
---|
82 | } |
---|
83 | |
---|
84 | //Add the Auth-Application-Id |
---|
85 | { |
---|
86 | CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Application_Id, 0, &avp ) ); |
---|
87 | value.i32 = 6; |
---|
88 | CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); |
---|
89 | CHECK_FCT( fd_msg_avp_add ( message, MSG_BRW_LAST_CHILD, avp) ); |
---|
90 | } |
---|
91 | //Auth_Session_State |
---|
92 | { |
---|
93 | CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Session_State, 0, &avp ) ); |
---|
94 | value.i32=1; |
---|
95 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) ); |
---|
96 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) ); |
---|
97 | } |
---|
98 | |
---|
99 | //Origin_Host & Origin_Realm |
---|
100 | CHECK_FCT( fd_msg_add_origin ( message, 0 )); |
---|
101 | |
---|
102 | //Destination_Host |
---|
103 | { |
---|
104 | CHECK_FCT( fd_msg_avp_new ( sip_dict.Destination_Host, 0, &avp ) ); |
---|
105 | value.os.data=(unsigned char *)destination_host; |
---|
106 | value.os.len=destination_hostlen; |
---|
107 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) ); |
---|
108 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) ); |
---|
109 | } |
---|
110 | //Destination_Realm |
---|
111 | { |
---|
112 | CHECK_FCT( fd_msg_avp_new ( sip_dict.Destination_Realm, 0, &avp ) ); |
---|
113 | value.os.data=(unsigned char *)destination_realm; |
---|
114 | value.os.len=destination_realmlen; |
---|
115 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) ); |
---|
116 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) ); |
---|
117 | } |
---|
118 | |
---|
119 | //SIP_AOR |
---|
120 | { |
---|
121 | |
---|
122 | CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_AOR, 0, &avp ) ); |
---|
123 | value.os.data=(unsigned char *)sip_aor; |
---|
124 | value.os.len=aor_len; |
---|
125 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) ); |
---|
126 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) ); |
---|
127 | |
---|
128 | } |
---|
129 | //Username |
---|
130 | { |
---|
131 | |
---|
132 | CHECK_FCT( fd_msg_avp_new ( sip_dict.User_Name, 0, &avp ) ); |
---|
133 | value.os.data=(unsigned char *)username; |
---|
134 | value.os.len=usernamelen; |
---|
135 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) ); |
---|
136 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) ); |
---|
137 | |
---|
138 | } |
---|
139 | //SIP_User_Data_Already_Available |
---|
140 | { |
---|
141 | CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_User_Data_Already_Available, 0, &avp ) ); |
---|
142 | value.i32=data_already_available; |
---|
143 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) ); |
---|
144 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) ); |
---|
145 | } |
---|
146 | |
---|
147 | //SIP_Server_Assignment_Type; |
---|
148 | { |
---|
149 | CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_Assignment_Type, 0, &avp ) ); |
---|
150 | value.i32=assignment_type; |
---|
151 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) ); |
---|
152 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) ); |
---|
153 | } |
---|
154 | //SIP_server_uri |
---|
155 | { |
---|
156 | |
---|
157 | CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_URI, 0, &avp ) ); |
---|
158 | value.os.data=(unsigned char *)sipserveruri; |
---|
159 | value.os.len=sipserverurilen; |
---|
160 | CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) ); |
---|
161 | CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) ); |
---|
162 | |
---|
163 | } |
---|
164 | |
---|
165 | fd_msg_dump_walk(INFO,message); |
---|
166 | CHECK_FCT( fd_msg_send( &message, NULL, NULL )); |
---|
167 | |
---|
168 | return 0; |
---|
169 | } |
---|
170 | |
---|
171 | int test_sip_SAA_cb( struct msg ** msg, struct avp * paramavp, struct session * sess, void * opaque, enum disp_action * act) |
---|
172 | { |
---|
173 | |
---|
174 | return 0; |
---|
175 | } |
---|