/[resiprocate]/branches/b-directory-reorg/sip/resiprocate/Transport.hxx
ViewVC logotype

Contents of /branches/b-directory-reorg/sip/resiprocate/Transport.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5271 - (show annotations) (download)
Thu Aug 18 23:43:07 2005 UTC (14 years, 3 months ago) by jason
File size: 7169 byte(s)
new directory reorg proposal
1 #if !defined(RESIP_TRANSPORT_HXX)
2 #define RESIP_TRANSPORT_HXX
3
4 #include "resiprocate/os/BaseException.hxx"
5 #include "resiprocate/os/Data.hxx"
6 #include "resiprocate/os/Fifo.hxx"
7 #include "resiprocate/os/Tuple.hxx"
8
9 namespace resip
10 {
11
12 class TransactionMessage;
13 class SipMessage;
14 class Connection;
15
16 class Transport
17 {
18 public:
19 class Exception : public BaseException
20 {
21 public:
22 Exception(const Data& msg, const Data& file, const int line);
23 const char* name() const { return "TransportException"; }
24 };
25
26 // portNum is the port to receive and/or send on
27 Transport(Fifo<TransactionMessage>& rxFifo,
28 const GenericIPAddress& address,
29 const Data& tlsDomain = Data::Empty);
30
31 Transport(Fifo<TransactionMessage>& rxFifo,
32 int portNum,
33 IpVersion version,
34 const Data& interfaceObj,
35 const Data& tlsDomain = Data::Empty);
36
37 virtual ~Transport();
38
39 virtual bool isFinished() const=0;
40
41 virtual void send( const Tuple& tuple, const Data& data, const Data& tid);
42 virtual void process(FdSet& fdset) = 0;
43 virtual void buildFdSet( FdSet& fdset) =0;
44
45 void fail(const Data& tid); // called when transport failed
46 static void error(int e);
47
48 // These methods are used by the TransportSelector
49 const Data& interfaceName() const { return mInterface; }
50
51 int port() const { return mTuple.getPort(); }
52 bool isV4() const { return mTuple.isV4(); } //!dcm! -- deprecate ASAP
53 IpVersion ipVersion() const { return mTuple.ipVersion(); }
54
55 const Data& tlsDomain() const { return mTlsDomain; }
56 const sockaddr& boundInterface() const { return mTuple.getSockaddr(); }
57 const Tuple& getTuple() const { return mTuple; }
58
59 virtual TransportType transport() const =0 ;
60 virtual bool isReliable() const =0;
61
62 // Perform basic sanity checks on message. Return false
63 // if there is a problem eg) no Vias. --SIDE EFFECT--
64 // This will queue a response if it CAN for a via-less
65 // request. Response will go straight into the TxFifo
66
67 bool basicCheck(const SipMessage& msg);
68
69 void makeFailedResponse(const SipMessage& msg,
70 int responseCode = 400,
71 const char * warning = 0);
72
73 // mark the received= and rport parameters if necessary
74 static void stampReceived(SipMessage* request);
75
76 /**
77 Returns true if this Transport should be included in the FdSet processing
78 loop, false if the Transport will provide its own cycles. If the Transport
79 is going to provide its own cycles, the startOwnProcessing() and
80 shutdown() will be called to tell the Transport when to process.
81
82 @retval true will run in the SipStack's processing context
83 @retval false provides own cycles, just puts messages in rxFifo
84 */
85 virtual bool shareStackProcessAndSelect() const=0;
86
87 //transports that returned false to shareStackProcessAndSelect() shouldn't
88 //put messages into the fifo until this is called
89 //?dcm? avoid the received a message but haven't added a transport to the
90 //TransportSelector race, but this might not be necessary.
91 virtual void startOwnProcessing()=0;
92
93 //only applies to transports that shareStackProcessAndSelect
94 virtual bool hasDataToSend() const = 0;
95
96 //overriding implementations should chain through to this
97 //?dcm? pure virtual protected method to enforce this?
98 virtual void shutdown()
99 {
100 // !jf! should use the fifo to pass this in
101 mShuttingDown = true;
102 }
103
104 // also used by the TransportSelector.
105 // requires that the two transports be
106 bool operator==(const Transport& rhs) const;
107
108 //# queued messages on this transport
109 virtual unsigned int getFifoSize() const=0;
110
111 protected:
112 Data mInterface;
113 Tuple mTuple;
114
115 Fifo<TransactionMessage>& mStateMachineFifo; // passed in
116 bool mShuttingDown;
117
118 //not a great name, just adds the message to the fifo in the synchronous(default) case,
119 //actually transmits in the asyncronous case. Don't make a SendData because asynchronous
120 //transports would require another copy.
121 virtual void transmit(const Tuple& dest, const Data& pdata, const Data& tid) = 0;
122
123 void setTlsDomain(const Data& domain) { mTlsDomain = domain; }
124 private:
125 static const Data transportNames[MAX_TRANSPORT];
126 friend std::ostream& operator<<(std::ostream& strm, const Transport& rhs);
127
128 Data mTlsDomain;
129 };
130
131 std::ostream& operator<<(std::ostream& strm, const Transport& rhs);
132
133 }
134
135 #endif
136
137 /* ====================================================================
138 * The Vovida Software License, Version 1.0
139 *
140 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
141 *
142 * Redistribution and use in source and binary forms, with or without
143 * modification, are permitted provided that the following conditions
144 * are met:
145 *
146 * 1. Redistributions of source code must retain the above copyright
147 * notice, this list of conditions and the following disclaimer.
148 *
149 * 2. Redistributions in binary form must reproduce the above copyright
150 * notice, this list of conditions and the following disclaimer in
151 * the documentation and/or other materials provided with the
152 * distribution.
153 *
154 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
155 * and "Vovida Open Communication Application Library (VOCAL)" must
156 * not be used to endorse or promote products derived from this
157 * software without prior written permission. For written
158 * permission, please contact vocal@vovida.org.
159 *
160 * 4. Products derived from this software may not be called "VOCAL", nor
161 * may "VOCAL" appear in their name, without prior written
162 * permission of Vovida Networks, Inc.
163 *
164 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
165 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
166 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
167 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
168 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
169 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
170 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
171 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
172 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
173 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
174 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
175 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
176 * DAMAGE.
177 *
178 * ====================================================================
179 *
180 * This software consists of voluntary contributions made by Vovida
181 * Networks, Inc. and many individuals on behalf of Vovida Networks,
182 * Inc. For more information on Vovida Networks, Inc., please see
183 * <http://www.vovida.org/>.
184 *
185 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27