fixed a bug in qse_dhcp6_find_option()

renamed SocketAddress::setIpaddr to setIp6addr/setIp4addr
This commit is contained in:
hyung-hwan 2018-10-23 09:13:28 +00:00
parent 95a41ab8a1
commit c56088d21a
3 changed files with 14 additions and 7 deletions

View File

@ -64,9 +64,9 @@ public:
return QSE_SIZEOF(this->skad); return QSE_SIZEOF(this->skad);
} }
void setIpaddr (const qse_ip4ad_t* ipaddr) QSE_CPP_NOEXCEPT; void setIp4addr (qse_uint32_t ipaddr) QSE_CPP_NOEXCEPT;
void setIpaddr (const qse_ip6ad_t* ipaddr) QSE_CPP_NOEXCEPT; void setIp4addr (const qse_ip4ad_t* ipaddr) QSE_CPP_NOEXCEPT;
void setIpaddr (qse_uint32_t ipaddr) QSE_CPP_NOEXCEPT; void setIp6addr (const qse_ip6ad_t* ipaddr) QSE_CPP_NOEXCEPT;
const qse_ip4ad_t* getIp4addr () const QSE_CPP_NOEXCEPT; const qse_ip4ad_t* getIp4addr () const QSE_CPP_NOEXCEPT;
const qse_ip6ad_t* getIp6addr () const QSE_CPP_NOEXCEPT; const qse_ip6ad_t* getIp6addr () const QSE_CPP_NOEXCEPT;

View File

@ -23,8 +23,15 @@ qse_dhcp6_opt_hdr_t* qse_dhcp6_find_option (const qse_dhcp6_pktinf_t* pkt, int c
while (rem >= QSE_SIZEOF(qse_dhcp6_opt_hdr_t)) while (rem >= QSE_SIZEOF(qse_dhcp6_opt_hdr_t))
{ {
if (qse_ntoh16(opt->code) == code) return opt; if (qse_ntoh16(opt->code) == code)
{
if (rem - QSE_SIZEOF(qse_dhcp6_opt_hdr_t) < qse_ntoh16(opt->len)) return QSE_NULL; /* probably the packet is ill-formed */
return opt;
}
rem -= QSE_SIZEOF(qse_dhcp6_opt_hdr_t) + qse_ntoh16(opt->len); rem -= QSE_SIZEOF(qse_dhcp6_opt_hdr_t) + qse_ntoh16(opt->len);
opt = (qse_dhcp6_opt_hdr_t*)((qse_uint8_t*)(opt + 1) + qse_ntoh16(opt->len));
} }
return QSE_NULL; return QSE_NULL;

View File

@ -108,7 +108,7 @@ int SocketAddress::getFamily () const QSE_CPP_NOEXCEPT
//return qse_skadfamily (&this->skad); //return qse_skadfamily (&this->skad);
} }
void SocketAddress::setIpaddr (const qse_ip4ad_t* ipaddr) QSE_CPP_NOEXCEPT void SocketAddress::setIp4addr (const qse_ip4ad_t* ipaddr) QSE_CPP_NOEXCEPT
{ {
#if defined(AF_INET) #if defined(AF_INET)
if (FAMILY(&this->skad) == AF_INET) if (FAMILY(&this->skad) == AF_INET)
@ -119,7 +119,7 @@ void SocketAddress::setIpaddr (const qse_ip4ad_t* ipaddr) QSE_CPP_NOEXCEPT
#endif #endif
} }
void SocketAddress::setIpaddr (const qse_uint32_t ipaddr) QSE_CPP_NOEXCEPT void SocketAddress::setIp4addr (const qse_uint32_t ipaddr) QSE_CPP_NOEXCEPT
{ {
#if defined(AF_INET) #if defined(AF_INET)
if (FAMILY(&this->skad) == AF_INET) if (FAMILY(&this->skad) == AF_INET)
@ -130,7 +130,7 @@ void SocketAddress::setIpaddr (const qse_uint32_t ipaddr) QSE_CPP_NOEXCEPT
#endif #endif
} }
void SocketAddress::setIpaddr (const qse_ip6ad_t* ipaddr) QSE_CPP_NOEXCEPT void SocketAddress::setIp6addr (const qse_ip6ad_t* ipaddr) QSE_CPP_NOEXCEPT
{ {
#if defined(AF_INET6) #if defined(AF_INET6)
if (FAMILY(&this->skad) == AF_INET6) if (FAMILY(&this->skad) == AF_INET6)