本文整理汇总了C++中NetworkAdapter::Subnet方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkAdapter::Subnet方法的具体用法?C++ NetworkAdapter::Subnet怎么用?C++ NetworkAdapter::Subnet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkAdapter
的用法示例。
在下文中一共展示了NetworkAdapter::Subnet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NifsMatch
TBool MdnsPlatform::NifsMatch(const NetworkAdapter& aNif1, const NetworkAdapter& aNif2)
{
if (aNif1.Address() == aNif2.Address() && aNif1.Subnet() == aNif2.Subnet() && strcmp(aNif1.Name(), aNif2.Name()) == 0) {
return true;
}
return false;
}
示例2: HandleInterfaceChange
void DviProtocolUpnp::HandleInterfaceChange()
{
TBool update = false;
std::vector<DviProtocolUpnpAdapterSpecificData*> pendingDelete;
{
const TIpAddress kLoopbackAddr = MakeIpAddress(127, 0, 0, 1);
AutoMutex a(iLock);
NetworkAdapterList& adapterList = iDvStack.Env().NetworkAdapterList();
AutoNetworkAdapterRef ref(iDvStack.Env(), "DviProtocolUpnp::HandleInterfaceChange");
const NetworkAdapter* current = ref.Adapter();
TUint i = 0;
std::vector<NetworkAdapter*>* subnetList = adapterList.CreateSubnetList();
std::vector<NetworkAdapter*>* adapters = adapterList.CreateNetworkAdapterList();
// remove listeners whose interface is no longer available
while (i<iAdapters.size()) {
if (FindAdapter(iAdapters[i]->Interface(), *adapters) != -1
&& (!adapterList.SingleSubnetModeEnabled() ||
(current != NULL && iAdapters[i]->Interface() == current->Address()) ||
iAdapters[i]->Interface() == kLoopbackAddr)) {
i++;
}
else {
iAdapters[i]->SetPendingDelete();
pendingDelete.push_back(iAdapters[i]);
iAdapters.erase(iAdapters.begin() + i);
}
}
// add listeners for new subnets
for (i=0; i<subnetList->size(); i++) {
NetworkAdapter* subnet = (*subnetList)[i];
if (FindListenerForSubnet(subnet->Subnet()) == -1) {
AddInterface(*subnet);
update = iDevice.Enabled();
}
}
NetworkAdapterList::DestroyNetworkAdapterList(adapters);
NetworkAdapterList::DestroySubnetList(subnetList);
if (update) {
// halt any ssdp broadcasts/responses that are currently in progress
// (in case they're for a subnet that's no longer valid)
// they'll be advertised again by the SendUpdateNotifications() call below
iDvStack.SsdpNotifierManager().Stop(iDevice.Udn());
}
}
for (TUint i=0; i<pendingDelete.size(); i++) {
pendingDelete[i]->Destroy();
}
if (update) {
SendUpdateNotifications();
}
}
示例3: TempFailureRetry
/*
void NetworkAdapterList::TempFailureRetry(Functor& aCallback)
{ // static
static const TUint kDelaysMs[] = { 100, 200, 400, 800, 1600, 3200, 5000, 10000, 20000, 20000, 30000 }; // roughly 90s worth of retries
for (TUint i=0; i<sizeof(kDelaysMs)/sizeof(kDelaysMs[0]); i++) {
try {
aCallback();
return;
}
catch (NetworkError&) {
LOG2(kNetwork, kError, "TempFailureRetry: error handling adapter change, try again in %ums\n", kDelaysMs[i]);
Thread::Sleep(kDelaysMs[i]);
}
}
THROW(NetworkError);
}
*/
std::vector<NetworkAdapter*>* NetworkAdapterList::CreateSubnetListLocked() const
{
std::vector<NetworkAdapter*>* list = new std::vector<NetworkAdapter*>;
for (TUint i=0; i<iNetworkAdapters->size(); i++) {
NetworkAdapter* nif = (*iNetworkAdapters)[i];
TIpAddress subnet = nif->Subnet();
if (-1 == NetworkAdapterList::FindSubnet(subnet, *list)) {
nif->AddRef("NetworkAdapterList");
list->push_back(nif);
}
}
return list;
}
示例4: SubnetListChanged
void DviServer::SubnetListChanged()
{
/* DviProtocolUpnp relies on servers being available on all appropriate interfaces.
We assume this happens through DviServer being created before any devices
so registering for subnet change notification earlier. Assuming NetworkAdapterList
always runs its listeners in the order they registered, we'll have updated before
any device listeners are run. */
AutoMutex a(iLock);
NetworkAdapterList& adapterList = iDvStack.Env().NetworkAdapterList();
AutoNetworkAdapterRef ref(iDvStack.Env(), "DviServer::SubnetListChanged");
NetworkAdapter* current = ref.Adapter();
if (adapterList.SingleSubnetModeEnabled()) {
TInt i;
// remove servers whose interface is no longer available
for (i = (TInt)iServers.size() - 1; i >= 0; i--) {
DviServer::Server* server = iServers[i];
if (current == NULL || server->Interface() != current->Address()) {
delete server;
iServers.erase(iServers.begin() + i);
}
}
// add server if 'current' is a new subnet
if (current != NULL && iServers.size() == 0) {
AddServer(*current);
}
}
else {
std::vector<NetworkAdapter*>* subnetList = adapterList.CreateSubnetList();
std::vector<NetworkAdapter*>* nifList = adapterList.CreateNetworkAdapterList();
TInt i;
// remove servers whose interface is no longer available
for (i = (TInt)iServers.size() - 1; i >= 0; i--) {
DviServer::Server* server = iServers[i];
if (FindInterface(server->Interface(), *nifList) == -1) {
delete server;
iServers.erase(iServers.begin() + i);
}
}
// add servers for new subnets
for (i = 0; i < (TInt)subnetList->size(); i++) {
NetworkAdapter* subnet = (*subnetList)[i];
if (FindServer(subnet->Subnet()) == -1) {
AddServer(*subnet);
}
}
NetworkAdapterList::DestroyNetworkAdapterList(nifList);
NetworkAdapterList::DestroySubnetList(subnetList);
}
}
示例5: iRefCount
DviProtocolUpnpAdapterSpecificData::DviProtocolUpnpAdapterSpecificData(DvStack& aDvStack, IUpnpMsearchHandler& aMsearchHandler, const NetworkAdapter& aAdapter, Bwx& aUriBase, TUint aServerPort)
: iRefCount(1)
, iDvStack(aDvStack)
, iMsearchHandler(&aMsearchHandler)
, iId(0x7fffffff)
, iSubnet(aAdapter.Subnet())
, iAdapter(aAdapter.Address())
, iUriBase(aUriBase)
, iServerPort(aServerPort)
, iBonjourWebPage(0)
, iDevice(NULL)
{
iListener = &(iDvStack.Env().MulticastListenerClaim(aAdapter.Address()));
iId = iListener->AddMsearchHandler(this);
}
示例6: UpdateCurrentAdapter
void NetworkAdapterList::UpdateCurrentAdapter()
{
iCurrent = NULL;
if (iNetworkAdapters != NULL && iNetworkAdapters->size() > 0) {
for (TUint i=0; i<iNetworkAdapters->size(); i++) {
NetworkAdapter* nif = (*iNetworkAdapters)[i];
if (nif->Subnet() == iDefaultSubnet) {
iCurrent = nif;
TraceAdapter("Subnet changed", *iCurrent);
break;
}
}
}
if (iCurrent == NULL) {
LOG(kTrace, "Subnet changed: none active\n");
}
}
示例7: OhNetNetworkAdapterSubnet
TIpAddress STDCALL OhNetNetworkAdapterSubnet(OhNetHandleNetworkAdapter aNif)
{
NetworkAdapter* nif = reinterpret_cast<NetworkAdapter*>(aNif);
ASSERT(nif != NULL);
return nif->Subnet();
}