Registered session protocol names. More...
#include <I_RecHttp.h>
Public Member Functions | |
SessionProtocolNameRegistry () | |
Default constructor. | |
~SessionProtocolNameRegistry () | |
Destructor. | |
int | toIndex (char const *name) |
Get the index for name, registering it if needed. | |
int | toIndexConst (char const *name) |
Get the index for name, registering it if needed. | |
int | indexFor (char const *name) const |
Convert a name to an index. | |
char const * | nameFor (int index) const |
Convert an index to the corresponding name. | |
void | markIn (char const *value, SessionProtocolSet &sp_set) |
Mark protocols as present in sp_set based on the names in value. | |
Static Public Attributes | |
static int const | MAX = SessionProtocolSet::MAX |
Maximum # of registered names. | |
static int const | INVALID = -1 |
Normalized invalid index value. | |
Protected Attributes | |
unsigned int | m_n |
Index of first unused slot. | |
char const * | m_names [MAX] |
Pointers to registered names. | |
uint8_t | m_flags [MAX] |
Flags for each name. | |
Static Protected Attributes | |
static uint8_t const | F_ALLOCATED = 0x1 |
Flag for allocated by this instance. |
Registered session protocol names.
We do this to avoid lots of string compares. By normalizing the string names we can just compare their indices in this table.
Definition at line 110 of file I_RecHttp.h.
SessionProtocolNameRegistry::SessionProtocolNameRegistry | ( | ) |
Default constructor.
Creates empty registry with no names.
Definition at line 602 of file RecHttp.cc.
SessionProtocolNameRegistry::~SessionProtocolNameRegistry | ( | ) |
Destructor.
Cleans up strings.
Definition at line 609 of file RecHttp.cc.
References ats_free(), F_ALLOCATED, m_flags, m_n, and m_names.
int SessionProtocolNameRegistry::indexFor | ( | char const * | name | ) | const |
Convert a name to an index.
INVALID
if it is not registered. Definition at line 646 of file RecHttp.cc.
References INVALID, m_n, and m_names.
Referenced by toIndex(), and toIndexConst().
void SessionProtocolNameRegistry::markIn | ( | char const * | value, | |
SessionProtocolSet & | sp_set | |||
) |
Mark protocols as present in sp_set based on the names in value.
The names can be separated by ;/|,: and space.
Check special cases
Definition at line 403 of file RecHttp.cc.
References Tokenizer::Initialize(), SessionProtocolSet::markIn(), toIndex(), TS_NPN_PROTOCOL_GROUP_HTTP, TS_NPN_PROTOCOL_GROUP_HTTP2, and TS_NPN_PROTOCOL_GROUP_SPDY.
Referenced by HttpProxyPort::processSessionProtocolPreference().
char const * SessionProtocolNameRegistry::nameFor | ( | int | index | ) | const |
Convert an index to the corresponding name.
NULL
if the index isn't registered. Definition at line 655 of file RecHttp.cc.
Referenced by HttpProxyPort::print().
int SessionProtocolNameRegistry::toIndex | ( | char const * | name | ) |
Get the index for name, registering it if needed.
The name is copied internally.
Definition at line 617 of file RecHttp.cc.
References ats_strdup, F_ALLOCATED, indexFor(), ink_release_assert, INVALID, m_flags, m_n, m_names, and MAX.
Referenced by markIn().
int SessionProtocolNameRegistry::toIndexConst | ( | char const * | name | ) |
Get the index for name, registering it if needed.
The caller guarantees name is persistent and immutable.
Definition at line 632 of file RecHttp.cc.
References indexFor(), ink_release_assert, INVALID, m_n, m_names, and MAX.
Referenced by ts_session_protocol_well_known_name_indices_init().
uint8_t const SessionProtocolNameRegistry::F_ALLOCATED = 0x1 [static, protected] |
Flag for allocated by this instance.
Definition at line 156 of file I_RecHttp.h.
Referenced by toIndex(), and ~SessionProtocolNameRegistry().
int const SessionProtocolNameRegistry::INVALID = -1 [static] |
Normalized invalid index value.
Definition at line 113 of file I_RecHttp.h.
Referenced by indexFor(), toIndex(), and toIndexConst().
uint8_t SessionProtocolNameRegistry::m_flags[MAX] [protected] |
Flags for each name.
Definition at line 154 of file I_RecHttp.h.
Referenced by SessionProtocolNameRegistry(), toIndex(), and ~SessionProtocolNameRegistry().
unsigned int SessionProtocolNameRegistry::m_n [protected] |
Index of first unused slot.
Definition at line 152 of file I_RecHttp.h.
Referenced by indexFor(), nameFor(), toIndex(), toIndexConst(), and ~SessionProtocolNameRegistry().
char const* SessionProtocolNameRegistry::m_names[MAX] [protected] |
Pointers to registered names.
Definition at line 153 of file I_RecHttp.h.
Referenced by indexFor(), nameFor(), SessionProtocolNameRegistry(), toIndex(), toIndexConst(), and ~SessionProtocolNameRegistry().
int const SessionProtocolNameRegistry::MAX = SessionProtocolSet::MAX [static] |
Maximum # of registered names.
Definition at line 112 of file I_RecHttp.h.
Referenced by toIndex(), and toIndexConst().