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

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27