added qse_initnwadwithip4ad(), qse_initnwadwithip6ad()
added SocketAddress::ipaddrToStrBuf()
This commit is contained in:
		| @ -87,6 +87,14 @@ public: | |||||||
| 	qse_mchar_t* toStrBuf (qse_mchar_t* buf, qse_size_t len) const QSE_CPP_NOEXCEPT; | 	qse_mchar_t* toStrBuf (qse_mchar_t* buf, qse_size_t len) const QSE_CPP_NOEXCEPT; | ||||||
| 	qse_wchar_t* toStrBuf (qse_wchar_t* buf, qse_size_t len) const QSE_CPP_NOEXCEPT; | 	qse_wchar_t* toStrBuf (qse_wchar_t* buf, qse_size_t len) const QSE_CPP_NOEXCEPT; | ||||||
|  |  | ||||||
|  | 	static qse_mchar_t* ip4addrToStrBuf (const qse_ip4ad_t* ipaddr, qse_mchar_t* buf, qse_size_t len); | ||||||
|  | 	static qse_mchar_t* ip4addrToStrBuf (qse_uint32_t ipaddr, qse_mchar_t* buf, qse_size_t len); | ||||||
|  | 	static qse_mchar_t* ip6addrToStrBuf (const qse_ip6ad_t* ipaddr, qse_mchar_t* buf, qse_size_t len); | ||||||
|  | 	 | ||||||
|  | 	static qse_wchar_t* ip4addrToStrBuf (const qse_ip4ad_t* ipaddr, qse_wchar_t* buf, qse_size_t len); | ||||||
|  | 	static qse_wchar_t* ip4addrToStrBuf (qse_uint32_t ipaddr, qse_wchar_t* buf, qse_size_t len); | ||||||
|  | 	static qse_wchar_t* ip6addrToStrBuf (const qse_ip6ad_t* ipaddr, qse_wchar_t* buf, qse_size_t len); | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
| 	qse_skad_t skad; | 	qse_skad_t skad; | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -204,6 +204,19 @@ struct qse_skad_t | |||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | QSE_EXPORT void qse_initnwadwithip4ad ( | ||||||
|  | 	qse_nwad_t*        nwad, | ||||||
|  | 	qse_uint16_t       port, | ||||||
|  | 	const qse_ip4ad_t* ipad | ||||||
|  | ); | ||||||
|  |  | ||||||
|  | QSE_EXPORT void qse_initnwadwithip6ad ( | ||||||
|  | 	qse_nwad_t*        nwad, | ||||||
|  | 	qse_uint16_t       port, | ||||||
|  | 	const qse_ip6ad_t* ipad, | ||||||
|  | 	qse_uint32_t       scopeid | ||||||
|  | ); | ||||||
|  |  | ||||||
| QSE_EXPORT int qse_nwadequal ( | QSE_EXPORT int qse_nwadequal ( | ||||||
| 	const qse_nwad_t* x, | 	const qse_nwad_t* x, | ||||||
| 	const qse_nwad_t* y | 	const qse_nwad_t* y | ||||||
|  | |||||||
| @ -300,6 +300,54 @@ qse_mchar_t* SocketAddress::toStrBuf (qse_mchar_t* buf, qse_size_t len) const QS | |||||||
| 	return buf; | 	return buf; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | qse_mchar_t* SocketAddress::ip4addrToStrBuf (const qse_ip4ad_t* ipaddr, qse_mchar_t* buf, qse_size_t len) | ||||||
|  | { | ||||||
|  | 	qse_nwad_t nwad; | ||||||
|  | 	qse_initnwadwithip4ad (&nwad, 0, ipaddr); | ||||||
|  | 	qse_nwadtombs (&nwad, buf, len, QSE_NWADTOMBS_ALL); | ||||||
|  | 	return buf; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | qse_mchar_t* SocketAddress::ip4addrToStrBuf (qse_uint32_t ipaddr, qse_mchar_t* buf, qse_size_t len) | ||||||
|  | { | ||||||
|  | 	qse_nwad_t nwad; | ||||||
|  | 	qse_initnwadwithip4ad (&nwad, 0, (qse_ip4ad_t*)&ipaddr); | ||||||
|  | 	qse_nwadtombs (&nwad, buf, len, QSE_NWADTOMBS_ALL); | ||||||
|  | 	return buf; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | qse_mchar_t* SocketAddress::ip6addrToStrBuf (const qse_ip6ad_t* ipaddr, qse_mchar_t* buf, qse_size_t len) | ||||||
|  | { | ||||||
|  | 	qse_nwad_t nwad; | ||||||
|  | 	qse_initnwadwithip6ad (&nwad, 0, ipaddr, 0); | ||||||
|  | 	qse_nwadtombs (&nwad, buf, len, QSE_NWADTOMBS_ALL); | ||||||
|  | 	return buf; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | qse_wchar_t* SocketAddress::ip4addrToStrBuf (const qse_ip4ad_t* ipaddr, qse_wchar_t* buf, qse_size_t len) | ||||||
|  | { | ||||||
|  | 	qse_nwad_t nwad; | ||||||
|  | 	qse_initnwadwithip4ad (&nwad, 0, ipaddr); | ||||||
|  | 	qse_nwadtowcs (&nwad, buf, len, QSE_NWADTOWCS_ALL); | ||||||
|  | 	return buf; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | qse_wchar_t* SocketAddress::ip4addrToStrBuf (qse_uint32_t ipaddr, qse_wchar_t* buf, qse_size_t len) | ||||||
|  | { | ||||||
|  | 	qse_nwad_t nwad; | ||||||
|  | 	qse_initnwadwithip4ad (&nwad, 0, (qse_ip4ad_t*)&ipaddr); | ||||||
|  | 	qse_nwadtowcs (&nwad, buf, len, QSE_NWADTOWCS_ALL); | ||||||
|  | 	return buf; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | qse_wchar_t* SocketAddress::ip6addrToStrBuf (const qse_ip6ad_t* ipaddr, qse_wchar_t* buf, qse_size_t len) | ||||||
|  | { | ||||||
|  | 	qse_nwad_t nwad; | ||||||
|  | 	qse_initnwadwithip6ad (&nwad, 0, ipaddr, 0); | ||||||
|  | 	qse_nwadtowcs (&nwad, buf, len, QSE_NWADTOWCS_ALL); | ||||||
|  | 	return buf; | ||||||
|  | } | ||||||
|  |  | ||||||
| ///////////////////////////////// | ///////////////////////////////// | ||||||
| QSE_END_NAMESPACE(QSE) | QSE_END_NAMESPACE(QSE) | ||||||
| ///////////////////////////////// | ///////////////////////////////// | ||||||
|  | |||||||
| @ -34,6 +34,24 @@ | |||||||
|  |  | ||||||
| #include "../cmn/mem-prv.h" | #include "../cmn/mem-prv.h" | ||||||
|  |  | ||||||
|  |  | ||||||
|  | void qse_initnwadwithip4ad (qse_nwad_t* nwad, qse_uint16_t port,	const qse_ip4ad_t* ipad) | ||||||
|  | { | ||||||
|  | 	QSE_MEMSET (nwad, 0, QSE_SIZEOF(*nwad)); | ||||||
|  | 	nwad->type = QSE_NWAD_IN4; | ||||||
|  | 	nwad->u.in4.port = port; | ||||||
|  | 	nwad->u.in4.addr = *ipad; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | void qse_initnwadwithip6ad (qse_nwad_t* nwad, qse_uint16_t port, const qse_ip6ad_t* ipad, qse_uint32_t scopeid) | ||||||
|  | { | ||||||
|  | 	QSE_MEMSET (nwad, 0, QSE_SIZEOF(*nwad)); | ||||||
|  | 	nwad->type = QSE_NWAD_IN6; | ||||||
|  | 	nwad->u.in6.port = port; | ||||||
|  | 	nwad->u.in6.addr = *ipad; | ||||||
|  | 	nwad->u.in6.scope = scopeid; | ||||||
|  | } | ||||||
|  |  | ||||||
| int qse_nwadequal (const qse_nwad_t* x, const qse_nwad_t* y) | int qse_nwadequal (const qse_nwad_t* x, const qse_nwad_t* y) | ||||||
| { | { | ||||||
| 	if (x->type != y->type) return 0; | 	if (x->type != y->type) return 0; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user