reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
InternalTransport.hxx
Go to the documentation of this file.
1#if !defined(RESIP_INTERNAL_TRANSPORT_HXX)
2#define RESIP_INTERNAL_TRANSPORT_HXX
3
4#include <exception>
5
8#include "rutil/Data.hxx"
9#include "rutil/Fifo.hxx"
10#include "rutil/Socket.hxx"
11#include "rutil/FdPoll.hxx"
14#include "resip/stack/Tuple.hxx"
18
19namespace resip
20{
21
22class TransactionMessage;
23class SipMessage;
24class Connection;
25class FdPollGrp;
26
31{
32 public:
33 // sendHost what to put in the Via:sent-by
34 // portNum is the port to receive and/or send on
36 int portNum,
37 IpVersion version,
38 const Data& interfaceObj,
39 AfterSocketCreationFuncPtr socketFunc = 0,
41 unsigned transportFlags = 0,
42 const Data& netNs = Data::Empty);
43
44 virtual ~InternalTransport();
45
46 virtual bool isFinished() const;
47 virtual bool hasDataToSend() const;
48
51
52 // No-op, even if this Transport is marked as having its own thread. It is the
53 // responsibility of the app-writer to ensure that a TransportThread is
54 // created for this Transport, and run it.
55 virtual void startOwnProcessing() {}
56
57 // shared by UDP, TCP, and TLS
58 static Socket socket(TransportType type, IpVersion ipVer);
59 void bind();
60
61 //used for event loop
62 virtual void setPollGrp(FdPollGrp *grp);
63
64 // used for statistics
65 virtual unsigned int getFifoSize() const;
66 virtual void send(std::unique_ptr<SendData> data);
67 virtual void poke();
68
69 // .bwc. This needs to be overridden if this transport runs in its own
70 // thread to be threadsafe.
83
84 virtual void invokeAfterSocketCreationFunc() const;
85
86 protected:
87 friend class SipStack;
88
89 virtual Socket getListenerSocket() const { return mFd; }
90
91 Socket mFd; // this is a unix file descriptor or a windows SOCKET
92
93 // .bwc. We use this to interrupt the select call when our tx fifo goes
94 // from empty to non-empty; if the fifo is empty when we build our fd set,
95 // we will add the read end of this pipe to the fd set, and when a message
96 // is added, we will write something to the write end.
99
100 Fifo<SendData> mTxFifo; // owned by the transport
102 FdPollGrp *mPollGrp; // not owned by transport, just used
103 // FdPollItemIf *mPollItem; // owned by the transport
104 FdPollItemHandle mPollItemHandle; // owned by the transport
105};
106
107
108}
109
110#endif
111
112/* ====================================================================
113 * The Vovida Software License, Version 1.0
114 *
115 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
116 *
117 * Redistribution and use in source and binary forms, with or without
118 * modification, are permitted provided that the following conditions
119 * are met:
120 *
121 * 1. Redistributions of source code must retain the above copyright
122 * notice, this list of conditions and the following disclaimer.
123 *
124 * 2. Redistributions in binary form must reproduce the above copyright
125 * notice, this list of conditions and the following disclaimer in
126 * the documentation and/or other materials provided with the
127 * distribution.
128 *
129 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
130 * and "Vovida Open Communication Application Library (VOCAL)" must
131 * not be used to endorse or promote products derived from this
132 * software without prior written permission. For written
133 * permission, please contact vocal@vovida.org.
134 *
135 * 4. Products derived from this software may not be called "VOCAL", nor
136 * may "VOCAL" appear in their name, without prior written
137 * permission of Vovida Networks, Inc.
138 *
139 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
140 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
141 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
142 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
143 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
144 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
145 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
146 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
147 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
148 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
149 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
150 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
151 * DAMAGE.
152 *
153 * ====================================================================
154 *
155 * This software consists of voluntary contributions made by Vovida
156 * Networks, Inc. and many individuals on behalf of Vovida Networks,
157 * Inc. For more information on Vovida Networks, Inc., please see
158 * <http://www.vovida.org/>.
159 *
160 * vi: set shiftwidth=3 expandtab:
161 */
Handles cross-platform sockets compatibility.
#define RESIP_TRANSPORT_FLAG_OWNTHREAD
Definition Transport.hxx:69
static Compression Disabled
Represents a compression configuration object with compression disabled.
Abstract base class that provides a basic congestion management interface.
virtual void unregisterFifo(resip::FifoStatsInterface *fifo)=0
Unregisters a fifo with the congestion manager.
virtual void registerFifo(resip::FifoStatsInterface *fifo)=0
Registers a fifo with the congestion manager.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
A templated, threadsafe message-queue class.
Definition Fifo.hxx:16
virtual bool shareStackProcessAndSelect() const
Returns true if this Transport should be included in the FdSet processing loop, false if the Transpor...
virtual void poke()
Called when a writer is done adding messages to the TxFifo; this is used to interrupt the select call...
virtual void startOwnProcessing()
transports that returned false to shareStackProcessAndSelect() shouldn't put messages into the fifo u...
static Socket socket(TransportType type, IpVersion ipVer)
virtual void setCongestionManager(CongestionManager *manager)
SelectInterruptor mSelectInterruptor
virtual unsigned int getFifoSize() const
virtual void send(std::unique_ptr< SendData > data)
virtual bool isFinished() const
virtual Socket getListenerSocket() const
The transport's own listening or bound socket, or INVALID_SOCKET for a transport that holds none.
ConsumerFifoBuffer< SendData > mTxFifoOutBuffer
FdPollItemHandle mInterruptorHandle
virtual void invokeAfterSocketCreationFunc() const
virtual bool hasDataToSend() const
only applies to transports that shareStackProcessAndSelect
virtual void setPollGrp(FdPollGrp *grp)
Used to 'artificially' interrupt a select call.
This is the primary point of interaction between the app-layer and the stack.
Definition SipStack.hxx:160
The base class for Transport classes.
Definition Transport.hxx:83
unsigned mTransportFlags
CongestionManager * mCongestionManager
virtual void setCongestionManager(CongestionManager *manager)
const Data & netNs() const
dcm! – add UnusedChecking(_enum) below;
void(* AfterSocketCreationFuncPtr)(Socket s, int transportType, const char *file, int line)
Definition Socket.hxx:107
int Socket
Definition Socket.hxx:94
struct FdPollItemFake * FdPollItemHandle
This is opaque type used to identify a particular Item.
Definition FdPoll.hxx:42
TransportType
An enumeration of transport protocols.
IpVersion
An enumeration of IP versions.