reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
WsDecorator.cxx
Go to the documentation of this file.
1#include "WsDecorator.hxx"
2
3#include "SipMessage.hxx"
4#include "Tuple.hxx"
5#include "Transport.hxx"
7
8using namespace std;
9using namespace resip;
10
14
18
19void
20WsDecorator::decorateMessage(resip::SipMessage &msg, const resip::Tuple &source, const resip::Tuple &destination, const resip::Data& sigcompId)
21{
22 const resip::Tuple& wsSource = msg.getSource();
23
24 if(wsSource.getType() == resip::WS)
25 {
26 if(msg.exists(resip::h_Contacts))
27 {
28 resip::NameAddr& contact = msg.header(resip::h_Contacts).front();
29
30 if (isEqualNoCase(contact.uri().host(), resip::Data("df7jal23ls0d.invalid")))
31 {
32 contact.uri().host() = resip::Tuple::inet_ntop(source);
33 contact.uri().port() = source.getPort();
34 contact.uri().param(resip::p_transport) = resip::Tuple::toDataLower(source.getType());
35
36 contact.uri().param(resip::p_wsSrcIp) = resip::Tuple::inet_ntop(wsSource);
37 contact.uri().param(resip::p_wsSrcPort) = wsSource.getPort();
38 }
39 }
40
41 if(msg.exists(resip::h_Vias))
42 {
43 resip::Via &via = msg.header(resip::h_Vias).back();
44 if(isEqualNoCase(via.sentHost(), resip::Data("df7jal23ls0d.invalid")))
45 {
46 via.sentHost() = resip::Tuple::inet_ntop(wsSource);
47 via.sentPort() = wsSource.getPort();
48 via.transport() = "TCP"; // most servers get crazy if we send "WS" as transport
49 }
50 }
51 }
52}
53
54void
58
60{
61 return new WsDecorator(*this);
62}
63
64/* ====================================================================
65 *
66 * Copyright 2012 Doubango Telecom. All rights reserved.
67 *
68 * Redistribution and use in source and binary forms, with or without
69 * modification, are permitted provided that the following conditions
70 * are met:
71 *
72 * 1. Redistributions of source code must retain the above copyright
73 * notice, this list of conditions and the following disclaimer.
74 *
75 * 2. Redistributions in binary form must reproduce the above copyright
76 * notice, this list of conditions and the following disclaimer in
77 * the documentation and/or other materials provided with the
78 * distribution.
79 *
80 * 3. Neither the name of the author(s) nor the names of any contributors
81 * may be used to endorse or promote products derived from this software
82 * without specific prior written permission.
83 *
84 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
85 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE.
95 *
96 * ====================================================================
97 *
98 *
99 */
100
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
Represents a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
const Tuple & getSource() const
Returns the source tuple that the message was received from only makes sense for messages received fr...
Represents a network address.
Definition Tuple.hxx:59
static const Data & toDataLower(TransportType type)
Definition Tuple.cxx:933
int getPort() const
Definition Tuple.cxx:466
TransportType getType() const
Definition Tuple.hxx:122
static Data inet_ntop(const Tuple &tuple)
Converts the binary socket address to presentation format, via the DnsUtil::inet_ntop() method.
Definition Tuple.cxx:939
int & port()
Definition Uri.hxx:145
Data & host()
Definition Uri.hxx:40
const Data & param(const ExtensionParameter &param) const
Const accessor for non-natively-supported parameter types.
Represents the "via-parm" element in the RFC 3261 grammar.
Definition Via.hxx:18
Data & transport()
Definition Via.cxx:121
int & sentPort()
Definition Via.cxx:149
Data & sentHost()
Definition Via.cxx:135
virtual MessageDecorator * clone() const
virtual void rollbackMessage(SipMessage &msg)
virtual void decorateMessage(SipMessage &msg, const Tuple &source, const Tuple &destination, const Data &sigcompId)
dcm! – add UnusedChecking(_enum) below;
bool isEqualNoCase(const Data &left, const Data &right)
Definition Data.hxx:1116