reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TransactionMap.hxx
Go to the documentation of this file.
1#if !defined(RESIP_TRANSACTIONMAP_HXX)
2#define RESIP_TRANSACTIONMAP_HXX
3
4#include <unordered_map>
5#include "rutil/Data.hxx"
6
7namespace resip
8{
9 class TransactionState;
10
15{
16 public:
18
19 TransactionState* find( const Data& transactionId ) const;
20 void add( const Data& transactionId, TransactionState* state );
21 void erase( const Data& transactionId );
22 int size() const;
23
24 private:
25
26 // We treat branch parameters as case insensitive (RFC3261):
27 // 7.3.1 Header Field Format
28 // ....
29 // When comparing header fields, field names are always case-
30 // insensitive.Unless otherwise stated in the definition of a
31 // particular header field, field values, parameter names, and parameter
32 // values are case-insensitive.Tokens are always case-insensitive.
33 // Unless specified otherwise, values expressed as quoted strings are
34 // case-sensitive.
35
39 class BranchHasher
40 {
41 public:
42 inline size_t operator()(const Data& branch) const
43 {
44 // Branches are chosen by remote peers. With a fixed hash a sender
45 // could pick branches that all collide, making every transaction
46 // lookup on the stack thread scan all of them; the keyed hash
47 // prevents that (see KeyedDataHash).
48 return branch.keyedCaseInsensitiveHash();
49 }
50 };
51
55 class BranchEqual
56 {
57 public:
58 inline bool operator()(const Data& branch1, const Data& branch2) const
59 {
60 return isEqualNoCase(branch1,branch2);
61 }
62 };
63
64 std::unordered_map<Data, TransactionState*, BranchHasher, BranchEqual> mMap;
65};
66}
67
68#endif
69
70/* ====================================================================
71 * The Vovida Software License, Version 1.0
72 *
73 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
74 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
75 *
76 * Redistribution and use in source and binary forms, with or without
77 * modification, are permitted provided that the following conditions
78 * are met:
79 *
80 * 1. Redistributions of source code must retain the above copyright
81 * notice, this list of conditions and the following disclaimer.
82 *
83 * 2. Redistributions in binary form must reproduce the above copyright
84 * notice, this list of conditions and the following disclaimer in
85 * the documentation and/or other materials provided with the
86 * distribution.
87 *
88 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
89 * and "Vovida Open Communication Application Library (VOCAL)" must
90 * not be used to endorse or promote products derived from this
91 * software without prior written permission. For written
92 * permission, please contact vocal@vovida.org.
93 *
94 * 4. Products derived from this software may not be called "VOCAL", nor
95 * may "VOCAL" appear in their name, without prior written
96 * permission of Vovida Networks, Inc.
97 *
98 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
99 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
100 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
101 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
102 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
103 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
104 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
105 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
106 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
107 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
109 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
110 * DAMAGE.
111 *
112 * ====================================================================
113 *
114 * This software consists of voluntary contributions made by Vovida
115 * Networks, Inc. and many individuals on behalf of Vovida Networks,
116 * Inc. For more information on Vovida Networks, Inc., please see
117 * <http://www.vovida.org/>.
118 *
119 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
size_t keyedCaseInsensitiveHash() const
Creates a keyed hash based on the contents of this Data, after normalizing ASCII alphabetic character...
Definition Data.cxx:2379
void erase(const Data &transactionId)
void add(const Data &transactionId, TransactionState *state)
TransactionState * find(const Data &transactionId) const
dcm! – add UnusedChecking(_enum) below;
bool isEqualNoCase(const Data &left, const Data &right)
Definition Data.hxx:1116