tcp: (fixes #2263) GetOption returns const Options

This commit is contained in:
Natale Patriciello
2017-01-25 18:17:04 +01:00
parent 8696eda1f6
commit bfe75e3591
3 changed files with 9 additions and 9 deletions

View File

@@ -460,7 +460,7 @@ TcpHeader::CalculateHeaderLength () const
}
bool
TcpHeader::AppendOption (Ptr<TcpOption> option)
TcpHeader::AppendOption (Ptr<const TcpOption> option)
{
if (m_optionsLen + option->GetSerializedSize () <= m_maxOptionsLen)
{
@@ -491,8 +491,8 @@ TcpHeader::GetOptionList () const
return m_options;
}
Ptr<TcpOption>
TcpHeader::GetOption (uint8_t kind) const
Ptr<const TcpOption>
TcpHeader::GetOption(uint8_t kind) const
{
TcpOptionList::const_iterator i;

View File

@@ -47,7 +47,7 @@ public:
TcpHeader ();
virtual ~TcpHeader ();
typedef std::list< Ptr<TcpOption> > TcpOptionList; //!< List of TcpOption
typedef std::list< Ptr<const TcpOption> > TcpOptionList; //!< List of TcpOption
/**
* \brief Print a TCP header into an output stream
@@ -185,7 +185,7 @@ public:
* \param kind the option to retrieve
* \return Whether the header contains a specific kind of option, or 0
*/
Ptr<TcpOption> GetOption (uint8_t kind) const;
Ptr<const TcpOption> GetOption (uint8_t kind) const;
/**
* \brief Get the list of option in this header
@@ -217,7 +217,7 @@ public:
* \param option The option to append
* \return true if option has been appended, false otherwise
*/
bool AppendOption (Ptr<TcpOption> option);
bool AppendOption (Ptr<const TcpOption> option);
/**
* \brief Initialize the TCP checksum.

View File

@@ -1450,7 +1450,7 @@ TcpSocketBase::ReadOptions (const TcpHeader &tcpHeader)
for (it = options.begin (); it != options.end (); ++it)
{
const Ptr<TcpOption> option = (*it);
const Ptr<const TcpOption> option = (*it);
// Placeholder for a switch statement
}
}
@@ -2860,8 +2860,8 @@ TcpSocketBase::EstimateRtt (const TcpHeader& tcpHeader)
{ // Ok to use this sample
if (m_timestampEnabled && tcpHeader.HasOption (TcpOption::TS))
{
Ptr<TcpOptionTS> ts;
ts = DynamicCast<TcpOptionTS> (tcpHeader.GetOption (TcpOption::TS));
Ptr<const TcpOptionTS> ts;
ts = DynamicCast<const TcpOptionTS> (tcpHeader.GetOption (TcpOption::TS));
m = TcpOptionTS::ElapsedTimeFromTsValue (ts->GetEcho ());
}
else