/[resiprocate]/main/resip/stack/test/testDtlsTransport.cxx
ViewVC logotype

Annotation of /main/resip/stack/test/testDtlsTransport.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5879 - (hide annotations) (download)
Sat Feb 11 00:12:43 2006 UTC (13 years, 10 months ago) by derek
File size: 4281 byte(s)
update eol property
1 derek 5634 #if defined(HAVE_CONFIG_H)
2     #include "resip/stack/config.hxx"
3     #endif
4    
5     #include <sys/types.h>
6     #include <iostream>
7     #include <memory>
8    
9     #include "rutil/DnsUtil.hxx"
10     #include "rutil/Inserter.hxx"
11     #include "rutil/Logger.hxx"
12     #include "resip/stack/Helper.hxx"
13     #include "resip/stack/SipMessage.hxx"
14     #include "resip/stack/SipStack.hxx"
15     #include "resip/stack/Uri.hxx"
16    
17     using namespace resip;
18     using namespace std;
19    
20     #define RESIPROCATE_SUBSYSTEM Subsystem::SIP
21    
22    
23     int
24     main(int argc, char* argv[])
25     {
26     Log::initialize(Log::Cout, Log::Info ,"testDtlsTransport");
27    
28     Security* serverSecurity = new Security();
29     SipStack serverStack(serverSecurity);
30    
31     serverStack.addTransport(DTLS, 15060, V4, StunDisabled, Data::Empty, "127.0.0.1");
32     SipStack clientStack(serverSecurity);
33     clientStack.addTransport(DTLS, 25060, V4);
34    
35 derek 5669 NameAddr target("sip:bob@127.0.0.1:15060;transport=dtls");
36 derek 5634 NameAddr from("sip:alice@127.0.0.1");
37     NameAddr contact;
38     contact.uri().user() = "alice";
39    
40     SipMessage * msg = Helper::makeRequest(target, from, contact, INVITE);
41     clientStack.send(*msg);
42     delete msg;
43    
44     while(true)
45     {
46     {
47     FdSet fdset;
48     serverStack.buildFdSet(fdset);
49     fdset.selectMilliSeconds(50);
50     serverStack.process(fdset);
51     }
52    
53     SipMessage* msg = serverStack.receive();
54     if (msg && msg->isRequest())
55     {
56     SipMessage* resp = Helper::makeResponse(*msg, 400);
57     serverStack.send(*resp);
58     InfoLog( << "Generated 400 to: " << msg->brief());
59     delete resp;
60     }
61     delete msg;
62    
63     {
64     FdSet fdset;
65     clientStack.buildFdSet(fdset);
66     fdset.selectMilliSeconds(50);
67     clientStack.process(fdset);
68     }
69    
70 nagendra 5665 msg = clientStack.receive();
71 derek 5634 if (msg)
72     {
73     InfoLog( << "Got from server: " << msg->brief());
74     break;
75     }
76     }
77     return 0;
78     }
79     /* ====================================================================
80     * The Vovida Software License, Version 1.0
81     *
82     * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
83     *
84     * Redistribution and use in source and binary forms, with or without
85     * modification, are permitted provided that the following conditions
86     * are met:
87     *
88     * 1. Redistributions of source code must retain the above copyright
89     * notice, this list of conditions and the following disclaimer.
90     *
91     * 2. Redistributions in binary form must reproduce the above copyright
92     * notice, this list of conditions and the following disclaimer in
93     * the documentation and/or other materials provided with the
94     * distribution.
95     *
96     * 3. The names "VOCAL", "Vovida Open Communication Application Library",
97     * and "Vovida Open Communication Application Library (VOCAL)" must
98     * not be used to endorse or promote products derived from this
99     * software without prior written permission. For written
100     * permission, please contact vocal@vovida.org.
101     *
102     * 4. Products derived from this software may not be called "VOCAL", nor
103     * may "VOCAL" appear in their name, without prior written
104     * permission of Vovida Networks, Inc.
105     *
106     * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
107     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
108     * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
109     * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
110     * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
111     * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
112     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
113     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
114     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
115     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
116     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
117     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
118     * DAMAGE.
119     *
120     * ====================================================================
121     *
122     * This software consists of voluntary contributions made by Vovida
123     * Networks, Inc. and many individuals on behalf of Vovida Networks,
124     * Inc. For more information on Vovida Networks, Inc., please see
125     * <http://www.vovida.org/>.
126     *
127     */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27