blob: e07a5ad27f920bec9fed438a19d3d15e0c4045a3 [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_UAR_cb()
40{
41 struct dict_object * uar_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 *visitednetwork="Pink";
56 size_t visitednetworklen=strlen(visitednetwork);
57 int registrationtype = 2;
58 //Fake values STOP
59
60 //Create the base message for an RTR
61 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "User-Authorization-Request", &uar_model, ENOENT) );
62 CHECK_FCT( fd_msg_new (uar_model, 0, &message));
63
64
65
66 // Create a new session
67 {
68 CHECK_FCT( fd_msg_new_session( message, (os0_t)"appsip", CONSTSTRLEN("appsip") ) );
69 }
70
71 //Add the Auth-Application-Id
72 {
73 CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Application_Id, 0, &avp ) );
74 value.i32 = 6;
75 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
76 CHECK_FCT( fd_msg_avp_add ( message, MSG_BRW_LAST_CHILD, avp) );
77 }
78
79 //Auth_Session_State
80 {
81 CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Session_State, 0, &avp ) );
82 value.i32=1;
83 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
84 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
85 }
86
87 //Origin_Host & Origin_Realm
88 CHECK_FCT( fd_msg_add_origin ( message, 0 ));
89
90 //Destination_Host
91 {
92 CHECK_FCT( fd_msg_avp_new ( sip_dict.Destination_Host, 0, &avp ) );
93 value.os.data=(unsigned char *)destination_host;
94 value.os.len=destination_hostlen;
95 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
96 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
97 }
98 //Destination_Realm
99 {
100 CHECK_FCT( fd_msg_avp_new ( sip_dict.Destination_Realm, 0, &avp ) );
101 value.os.data=(unsigned char *)destination_realm;
102 value.os.len=destination_realmlen;
103 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
104 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
105 }
106
107 //SIP_AOR
108 {
109
110 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_AOR, 0, &avp ) );
111 value.os.data=(unsigned char *)sip_aor;
112 value.os.len=aor_len;
113 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
114 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
115
116 }
117 //Username
118 {
119
120 CHECK_FCT( fd_msg_avp_new ( sip_dict.User_Name, 0, &avp ) );
121 value.os.data=(unsigned char *)username;
122 value.os.len=usernamelen;
123 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
124 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
125
126 }
127 //Visited Network
128 {
129
130 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Visited_Network_Id, 0, &avp ) );
131 value.os.data=(unsigned char *)visitednetwork;
132 value.os.len=visitednetworklen;
133 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
134 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
135
136 }
137 //Authorization Type
138 {
139
140 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_User_Authorization_Type, 0, &avp ) );
141 value.i32=registrationtype;
142 CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
143 CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
144
145 }
146
147 CHECK_FCT( fd_msg_send( &message, NULL, NULL ));
148
149 return 0;
150}
151
152int test_sip_UAA_cb( struct msg ** msg, struct avp * paramavp, struct session * sess, void * opaque, enum disp_action * act)
153{
154
155 return 0;
156}