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

Contents of /main/resip/stack/test/testSocketFunc.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10230 - (show annotations) (download)
Tue Jun 18 17:43:59 2013 UTC (6 years, 4 months ago) by dpocock
File size: 3527 byte(s)
resip/stack: testSocketFunc: expand test case to WSS, add OpenSSL sample command for cert
1 #if defined(HAVE_CONFIG_H)
2 #include "config.h"
3 #endif
4
5 #include <sys/types.h>
6 #include <iostream>
7 #include <memory>
8
9 #include "rutil/GeneralCongestionManager.hxx"
10 #include "rutil/DnsUtil.hxx"
11 #include "rutil/Inserter.hxx"
12 #include "rutil/Logger.hxx"
13 #include "resip/stack/DeprecatedDialog.hxx"
14 #include "resip/stack/Helper.hxx"
15 #include "resip/stack/ssl/Security.hxx"
16 #include "resip/stack/SipMessage.hxx"
17 #include "resip/stack/SipStack.hxx"
18 #include "resip/stack/StackThread.hxx"
19 #include "rutil/SelectInterruptor.hxx"
20 #include "resip/stack/TransportThread.hxx"
21 #include "resip/stack/InterruptableStackThread.hxx"
22 #include "resip/stack/EventStackThread.hxx"
23 #include "resip/stack/Uri.hxx"
24
25 using namespace resip;
26 using namespace std;
27
28 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
29
30 /* prototype is in rutil/Socket.hxx:
31 typedef void(*AfterSocketCreationFuncPtr)(Socket s, int transportType, const char* file, int line); */
32
33 void afterSocketCreationFunction(Socket sock, int transport, const char *file, int line)
34 {
35 }
36
37 /* For TLS and WSS, it is necessary to create a key and cert with OpenSSL
38
39 openssl req -new -x509 -days 365 -nodes \
40 -out ~/.sipCerts/domain_cert_127.0.0.1.pem \
41 -keyout ~/.sipCerts/domain_key_127.0.0.1.pem \
42 -subj '/CN=127.0.0.1'
43
44 and then uncomment TLS and WSS below
45 */
46
47 int main()
48 {
49 Security *sec = new Security();
50 SipStack sipStack(sec, DnsStub::EmptyNameserverList, 0, false, &afterSocketCreationFunction);
51 sipStack.addTransport(UDP, 5060, V4, StunDisabled, Data::Empty, "127.0.0.1");
52 sipStack.addTransport(TCP, 5062, V4, StunDisabled, Data::Empty, "127.0.0.1");
53 //sipStack.addTransport(TLS, 5061, V4, StunDisabled, Data::Empty, "127.0.0.1");
54 //sipStack.addTransport(WSS, 8443, V4, StunDisabled, Data::Empty, "127.0.0.1");
55 return 0;
56 }
57
58
59 /* ====================================================================
60 *
61 * Copyright (c) 2013 Daniel Pocock All rights reserved.
62 *
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions
65 * are met:
66 *
67 * 1. Redistributions of source code must retain the above copyright
68 * notice, this list of conditions and the following disclaimer.
69 *
70 * 2. Redistributions in binary form must reproduce the above copyright
71 * notice, this list of conditions and the following disclaimer in
72 * the documentation and/or other materials provided with the
73 * distribution.
74 *
75 * 3. Neither the name of the author(s) nor the names of any contributors
76 * may be used to endorse or promote products derived from this software
77 * without specific prior written permission.
78 *
79 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
80 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
81 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
82 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
85 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
86 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
87 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
88 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
89 * SUCH DAMAGE.
90 *
91 * ====================================================================
92 *
93 *
94 */
95

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27