本文整理汇总了C++中TInetAddr::Ip6Address方法的典型用法代码示例。如果您正苦于以下问题:C++ TInetAddr::Ip6Address方法的具体用法?C++ TInetAddr::Ip6Address怎么用?C++ TInetAddr::Ip6Address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TInetAddr
的用法示例。
在下文中一共展示了TInetAddr::Ip6Address方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ILibSocketWrapper_joinmulticastgroup
int ILibSocketWrapper_joinmulticastgroup(int socketObject, long multicastAddress, long multicastInterface)
{
RSocket *s = (RSocket*)SocketArray[socketObject];
int RetVal;
TInetAddr dst;
dst.SetAddress(htonl(multicastAddress));
dst.SetPort(0);
dst.ConvertToV4Mapped();
TPckgBuf<TIp6Mreq> req;
req().iAddr = dst.Ip6Address();
req().iInterface = ILibSocketWrapper_GetInterfaceIndex(multicastInterface);
RetVal = s->SetOpt(KSoIp6JoinGroup,KSolInetIp,req);
if(RetVal==KErrNone)
{
return(0);
}
else
{
s->SetOpt(KSoIp6LeaveGroup,KSolInetIp,req);
return(-1);
}
}
示例2: qt_QHostAddressFromTInetAddr
QHostAddress qt_QHostAddressFromTInetAddr(const TInetAddr& addr)
{
if (addr.IsV4Mapped() || addr.Family() == KAfInet) {
//convert v4 host address
return QHostAddress(addr.Address());
} else {
//convert v6 host address
return QHostAddress((quint8 *)(addr.Ip6Address().u.iAddr8));
}
}
示例3: qt_QHostAddressFromTInetAddr
//TODO: share this, at least QHostInfo needs to do the same thing
static QHostAddress qt_QHostAddressFromTInetAddr(const TInetAddr& addr)
{
//TODO: do we want to call v4 mapped addresses v4 or v6 outside of this file?
if (addr.IsV4Mapped() || addr.Family() == KAfInet) {
//convert v4 host address
return QHostAddress(addr.Address());
} else {
//convert v6 host address
return QHostAddress((quint8 *)(addr.Ip6Address().u.iAddr8));
}
}
示例4: sizeof
/*
* Convert text to IPv4/IPv6 address.
*/
PJ_DEF(pj_status_t) pj_inet_pton(int af, const pj_str_t *src, void *dst)
{
char tempaddr[PJ_INET6_ADDRSTRLEN];
PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EINVAL);
PJ_ASSERT_RETURN(src && src->slen && dst, PJ_EINVAL);
/* Initialize output with PJ_IN_ADDR_NONE for IPv4 (to be
* compatible with pj_inet_aton()
*/
if (af==PJ_AF_INET) {
((pj_in_addr*)dst)->s_addr = PJ_INADDR_NONE;
}
/* Caution:
* this function might be called with cp->slen >= 46
* (i.e. when called with hostname to check if it's an IP addr).
*/
if (src->slen >= PJ_INET6_ADDRSTRLEN) {
return PJ_ENAMETOOLONG;
}
pj_memcpy(tempaddr, src->ptr, src->slen);
tempaddr[src->slen] = '\0';
wchar_t tempaddr16[PJ_INET6_ADDRSTRLEN];
pj_ansi_to_unicode(tempaddr, pj_ansi_strlen(tempaddr),
tempaddr16, sizeof(tempaddr16));
TBuf<PJ_INET6_ADDRSTRLEN> ip_addr((const TText*)tempaddr16);
TInetAddr addr;
addr.Init(KAfInet6);
if (addr.Input(ip_addr) == KErrNone) {
if (af==PJ_AF_INET) {
/* Success (Symbian IP address is in host byte order) */
pj_uint32_t ip = pj_htonl(addr.Address());
pj_memcpy(dst, &ip, 4);
} else if (af==PJ_AF_INET6) {
const TIp6Addr & ip6 = addr.Ip6Address();
pj_memcpy(dst, ip6.u.iAddr8, 16);
} else {
pj_assert(!"Unexpected!");
return PJ_EBUG;
}
return PJ_SUCCESS;
} else {
/* Error */
return PJ_EINVAL;
}
}
示例5: ASSERT
/**
* Called when the context has been activated to set our IP address and get
* any other required settings from CommDB.
*
* @param aConfig The new context config
*/
void CIPv6Binder::UpdateContextConfigL(const TPacketDataConfigBase& aConfig)
{
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_1, "CIPv6Binder::UpdateContextConfig");
// Get our IP address from the GPRS context config.
TInetAddr address;
TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr;
const RPacketContext::TProtocolConfigOptionV2* pco;
TInt rel = const_cast<TPacketDataConfigBase&>(aConfig).ExtensionId();
if (rel == TPacketDataConfigBase::KConfigGPRS)
{
tempAddr.Copy(static_cast<const RPacketContext::TContextConfigGPRS&>(aConfig).iPdpAddress);
pco = &static_cast<const RPacketContext::TContextConfigGPRS&>(aConfig).iProtocolConfigOption;
}
else
{
ASSERT(rel == TPacketDataConfigBase::KConfigRel99Rel4 || rel == TPacketDataConfigBase::KConfigRel5);
tempAddr.Copy(static_cast<const RPacketContext::TContextConfigR99_R4&>(aConfig).iPdpAddress);
pco = &static_cast<const RPacketContext::TContextConfigR99_R4&>(aConfig).iProtocolConfigOption;
}
TInt ret = address.Input(tempAddr);
// We've got our IP address! Let's save it.
if (ret == KErrNone)
{
iSettings.iLocalAddr = address.Ip6Address();
OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_2, "Got local IP address = %u:%u:%u:%u from context", iSettings.iLocalAddr.u.iAddr32[3], iSettings.iLocalAddr.u.iAddr32[2], iSettings.iLocalAddr.u.iAddr32[1], iSettings.iLocalAddr.u.iAddr32[0]);
}
else
{
OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_3, "Couldn't get IP address from GPRS config (err: %d)",ret);
// Don't leave on this error: we may still be OK if we read some
// settings from CommDB.
}
// @todo - is this correct. We can only get the DNS addresses
// from the TSY using the iProtocolConfigOption data. Yet a client could
// access those DNS config details without knowing about the state of the
// iSettings.iGetDnsFromServer flag.
if ((iSettings.iGetDnsFromServer) ||
((iSettings.iPrimaryDns.IsUnspecified()) &&
(iSettings.iSecondaryDns.IsUnspecified())) )
{
TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr;
tempAddr.Copy(pco->iDnsAddresses.iPrimaryDns);
ret = address.Input(tempAddr);
if (ret == KErrNone)
{
iSettings.iPrimaryDns = address.Ip6Address();
OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_4, "Got primary DNS = %u:%u:%u:%u from context", iSettings.iPrimaryDns.u.iAddr32[3], iSettings.iPrimaryDns.u.iAddr32[2], iSettings.iPrimaryDns.u.iAddr32[1], iSettings.iPrimaryDns.u.iAddr32[0]);
}
else
{
OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_5, "Couldn't get primary DNS address from GPRS config (err: %d)",ret);
// Don't leave on this error: we may still be OK if we read some
// settings from CommDB.
}
tempAddr.Copy(pco->iDnsAddresses.iSecondaryDns);
ret = address.Input(tempAddr);
if (ret == KErrNone)
{
iSettings.iSecondaryDns = address.Ip6Address();
OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_6, "Got secondary DNS = %u:%u:%u:%u from context", iSettings.iSecondaryDns.u.iAddr32[3], iSettings.iSecondaryDns.u.iAddr32[2], iSettings.iSecondaryDns.u.iAddr32[1], iSettings.iSecondaryDns.u.iAddr32[0]);
}
else
{
OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_7, "Couldn't get secondary DNS address from GPRS config (err: %d)",ret);
// Don't leave on this error: we may still be OK if we read some
// settings from CommDB.
}
}
else
{
OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_8, "Using CommDB DNS address - Primary = %u:%u:%u:%u", iSettings.iPrimaryDns.u.iAddr32[3], iSettings.iPrimaryDns.u.iAddr32[2], iSettings.iPrimaryDns.u.iAddr32[1], iSettings.iPrimaryDns.u.iAddr32[0]);
OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_9, " - Secondary = %u:%u:%u:%u", iSettings.iSecondaryDns.u.iAddr32[3], iSettings.iSecondaryDns.u.iAddr32[2], iSettings.iSecondaryDns.u.iAddr32[1], iSettings.iSecondaryDns.u.iAddr32[0]);
}
}