blob: 887ed2841dbed259a607025e0c44de59d59fd352 [file] [log] [blame]
Brian Waters13d96012017-12-08 16:53:31 -06001/*********************************************************************************************************
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
39int test_sip_SAR_cb()
40{
41 struct dict_object * sar_model=NULL;
42 struct msg * message=NULL;
43 struct avp *avp=NULL;
44 union avp_value value;
45
46 //Fake values START
47 char *sip_aor="sip:aw-lappy@tera.ics.keio.ac.jp";
48 size_t aor_len=strlen(sip_aor);
49 char *destination_realm="tera.ics.keio.ac.jp";
50 size_t destination_realmlen=strlen(destination_realm);
51 char *destination_host="suika.tera.ics.keio.ac.jp";
52 size_t destination_hostlen=strlen(destination_host);
53 char *username="aw-lappy";
54 size_t usernamelen=strlen(username);
55 char *sipserveruri="sip:ichigo@tera.ics.keio.ac.jp";
56 size_t sipserverurilen=strlen(sipserveruri);
57 // char *visitednetwork="Pink";
58 //size_t visitednetworklen=strlen(visitednetwork);
59 //int registrationtype = 2;
60 int data_already_available=0;
61 int assignment_type=0;
62 //Fake values STOP
63
64 //Create the base message for an RTR
65 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Server-Assignment-Request", &sar_model, ENOENT) );
66 CHECK_FCT( fd_msg_new (sar_model, 0, &message));
67
68
69
70 // Create a new session
71 {
72 CHECK_FCT( fd_msg_new_session( message, (os0_t)"appsip", CONSTSTRLEN("appsip") ) );
73 }
74
75 //Add the Auth-Application-Id
76 {
77 CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Application_Id, 0, &avp ) );
78 value.i32 = 6;
79 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
80 CHECK_FCT( fd_msg_avp_add ( message, MSG_BRW_LAST_CHILD, avp) );
81 }
82 //Auth_Session_State
83 {
84 CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Session_State, 0, &avp ) );
85 value.i32=1;
86 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
87 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
88 }
89
90 //Origin_Host & Origin_Realm
91 CHECK_FCT( fd_msg_add_origin ( message, 0 ));
92
93 //Destination_Host
94 {
95 CHECK_FCT( fd_msg_avp_new ( sip_dict.Destination_Host, 0, &avp ) );
96 value.os.data=(unsigned char *)destination_host;
97 value.os.len=destination_hostlen;
98 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
99 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
100 }
101 //Destination_Realm
102 {
103 CHECK_FCT( fd_msg_avp_new ( sip_dict.Destination_Realm, 0, &avp ) );
104 value.os.data=(unsigned char *)destination_realm;
105 value.os.len=destination_realmlen;
106 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
107 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
108 }
109
110 //SIP_AOR
111 {
112
113 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_AOR, 0, &avp ) );
114 value.os.data=(unsigned char *)sip_aor;
115 value.os.len=aor_len;
116 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
117 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
118
119 }
120 //Username
121 {
122
123 CHECK_FCT( fd_msg_avp_new ( sip_dict.User_Name, 0, &avp ) );
124 value.os.data=(unsigned char *)username;
125 value.os.len=usernamelen;
126 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
127 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
128
129 }
130 //SIP_User_Data_Already_Available
131 {
132 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_User_Data_Already_Available, 0, &avp ) );
133 value.i32=data_already_available;
134 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
135 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
136 }
137
138 //SIP_Server_Assignment_Type;
139 {
140 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_Assignment_Type, 0, &avp ) );
141 value.i32=assignment_type;
142 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
143 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
144 }
145 //SIP_server_uri
146 {
147
148 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_URI, 0, &avp ) );
149 value.os.data=(unsigned char *)sipserveruri;
150 value.os.len=sipserverurilen;
151 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
152 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
153
154 }
155
156 CHECK_FCT( fd_msg_send( &message, NULL, NULL ));
157
158 return 0;
159}
160
161int test_sip_SAA_cb( struct msg ** msg, struct avp * paramavp, struct session * sess, void * opaque, enum disp_action * act)
162{
163
164 return 0;
165}