/[resiprocate]/branches/b-identity-0505/ConnectionBase.hxx
ViewVC logotype

Contents of /branches/b-identity-0505/ConnectionBase.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4521 - (show annotations) (download)
Thu May 5 22:20:57 2005 UTC (14 years, 7 months ago) by derek
File size: 4830 byte(s)
branch for identity hacking
1 #if !defined(RESIP_CONNECTION_BASE_HXX)
2 #define RESIP_CONNECTION_BASE_HXX
3
4 /**
5 !dlb!
6 Relationship between buffer allocation and parsing is broken.
7
8 If the read returns with a few bytes, a new buffer is allocated in performRead.
9
10 performRead should handle allocation, read, and parsing. it should be the only
11 public read accessor in Connection. read should be protected.
12
13 !dcm! -- reworking Connection. Friendship is gone unless a
14 compelling arguement can be made, as ConnectionManager will now
15 have subclasses. Accessors now instead of direct access to private
16 memebers. All buffer stuff is hidden in read for synchronous
17 connections and handleRead for async connections.
18 */
19
20 #include <list>
21
22 #include "resiprocate/os/Timer.hxx"
23 #include "resiprocate/os/Fifo.hxx"
24 #include "resiprocate/Transport.hxx"
25 #include "resiprocate/MsgHeaderScanner.hxx"
26 #include "resiprocate/SendData.hxx"
27
28 namespace resip
29 {
30
31 class TransactionMessage;
32
33 class ConnectionBase
34 {
35 friend std::ostream& operator<<(std::ostream& strm, const resip::ConnectionBase& c);
36 public:
37 ConnectionBase(const Tuple& who);
38 ConnectionId getId() const;
39
40 Transport* transport();
41
42 Tuple& who() { return mWho; }
43 const UInt64& whenLastUsed() { return mLastUsed; }
44
45 enum { ChunkSize = 2048 }; // !jf! what is the optimal size here?
46
47 protected:
48 enum State
49 {
50 NewMessage = 0,
51 ReadingHeaders,
52 PartialBody,
53 MAX
54 };
55
56 State getCurrentState() const { return mState; }
57 void preparseNewBytes(int bytesRead, Fifo<TransactionMessage>& fifo);
58 std::pair<char*, size_t> getWriteBuffer();
59
60 // for avoiding copies in external transports--not used in core resip
61 void setBuffer(char* bytes, int count);
62
63 Data::size_type mSendPos;
64 std::list<SendData*> mOutstandingSends; // !jacob! intrusive queue?
65
66 ConnectionBase();
67 virtual ~ConnectionBase();
68 // no value semantics
69 ConnectionBase(const Connection&);
70 ConnectionBase& operator=(const Connection&);
71 protected:
72 Tuple mWho;
73 private:
74 SipMessage* mMessage;
75 char* mBuffer;
76 size_t mBufferPos;
77 size_t mBufferSize;
78
79 static char connectionStates[MAX][32];
80 UInt64 mLastUsed;
81 State mState;
82 MsgHeaderScanner mMsgHeaderScanner;
83 };
84
85 std::ostream&
86 operator<<(std::ostream& strm, const resip::ConnectionBase& c);
87
88 }
89
90 #endif
91 /* ====================================================================
92 * The Vovida Software License, Version 1.0
93 *
94 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
95 *
96 * Redistribution and use in source and binary forms, with or without
97 * modification, are permitted provided that the following conditions
98 * are met:
99 *
100 * 1. Redistributions of source code must retain the above copyright
101 * notice, this list of conditions and the following disclaimer.
102 *
103 * 2. Redistributions in binary form must reproduce the above copyright
104 * notice, this list of conditions and the following disclaimer in
105 * the documentation and/or other materials provided with the
106 * distribution.
107 *
108 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
109 * and "Vovida Open Communication Application Library (VOCAL)" must
110 * not be used to endorse or promote products derived from this
111 * software without prior written permission. For written
112 * permission, please contact vocal@vovida.org.
113 *
114 * 4. Products derived from this software may not be called "VOCAL", nor
115 * may "VOCAL" appear in their name, without prior written
116 * permission of Vovida Networks, Inc.
117 *
118 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
119 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
120 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
121 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
122 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
123 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
124 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
125 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
126 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
127 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
128 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
129 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
130 * DAMAGE.
131 *
132 * ====================================================================
133 *
134 * This software consists of voluntary contributions made by Vovida
135 * Networks, Inc. and many individuals on behalf of Vovida Networks,
136 * Inc. For more information on Vovida Networks, Inc., please see
137 * <http://www.vovida.org/>.
138 *
139 */

Properties

Name Value
svn:executable *

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27