Exemple #1
0
static void RandomiseUdn(DvStack& aDvStack, Bwh& aUdn)
{
    aUdn.Grow(aUdn.Bytes() + 1 + Ascii::kMaxUintStringBytes + 1);
    aUdn.Append('-');
    Bws<Ascii::kMaxUintStringBytes> buf;
    std::vector<NetworkAdapter*>* subnetList = aDvStack.Env().NetworkAdapterList().CreateSubnetList();
    TUint max = (*subnetList)[0]->Address();
    TUint seed = aDvStack.ServerUpnp().Port((*subnetList)[0]->Address());
    SetRandomSeed(seed);
    aDvStack.Env().NetworkAdapterList().DestroySubnetList(subnetList);
    (void)Ascii::AppendDec(buf, Random(max));
    aUdn.Append(buf);
    aUdn.PtrZ();
}
Exemple #2
0
void TestDvSubscription(CpStack& aCpStack, DvStack& aDvStack)
{
    Environment& env = aDvStack.Env();
    InitialisationParams& initParams = env.InitParams();
    TUint oldMsearchTime = initParams.MsearchTimeSecs();
    initParams.SetMsearchTime(1);
    Print("TestDvSubscription - starting\n");

    Semaphore* sem = new Semaphore("SEM1", 0);
    DeviceBasic* device = new DeviceBasic(aDvStack);
    CpDevices* deviceList = new CpDevices(*sem, device->Udn());
    FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &CpDevices::Added);
    FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &CpDevices::Removed);
    Brn domainName("openhome.org");
    Brn serviceType("TestBasic");
    TUint ver = 1;
    CpDeviceListUpnpServiceType* list =
                new CpDeviceListUpnpServiceType(aCpStack, domainName, serviceType, ver, added, removed);
    sem->Wait(30*1000); // allow up to 30 seconds to issue the msearch and receive a response
    delete sem;
    deviceList->Test();
    delete list;
    delete deviceList;
    delete device;

    Print("TestDvSubscription - completed\n");
    initParams.SetMsearchTime(oldMsearchTime);
}
Exemple #3
0
DvDevices::DvDevices(DvStack& aDvStack)
{
    RandomiseUdn(aDvStack.Env(), gNameDevice1);
    RandomiseUdn(aDvStack.Env(), gNameDevice1_1);
    RandomiseUdn(aDvStack.Env(), gNameDevice1_2);
    RandomiseUdn(aDvStack.Env(), gNameDevice2);

    DviDeviceStandard* device = new DviDeviceStandard(aDvStack, Brn(gNameDevice1));
    iDevices[0] = device;
    device->SetAttribute("Upnp.Domain", "a.b.c");
    device->SetAttribute("Upnp.Type", "test1");
    device->SetAttribute("Upnp.Version", "1");
    device->SetAttribute("Upnp.FriendlyName", (const TChar*)gNameDevice1.Ptr());
    AddService(device, new DviService(aDvStack, "a.b.c", "service1", 1));

    device = new DviDeviceStandard(aDvStack, Brn(gNameDevice1_1));
    iDevices[0]->AddDevice(device);
    device->SetAttribute("Upnp.Domain", "a.b.c");
    device->SetAttribute("Upnp.Type", "test3");
    device->SetAttribute("Upnp.Version", "1");
    device->SetAttribute("Upnp.FriendlyName", (const TChar*)gNameDevice1_1.Ptr());
    AddService(device, new DviService(aDvStack, "a.b.c", "service2", 1));
    AddService(device, new DviService(aDvStack, "a.b.c", "service3", 1));
    device->SetEnabled();

    device = new DviDeviceStandard(aDvStack, Brn(gNameDevice1_2));
    iDevices[0]->AddDevice(device);
    device->SetAttribute("Upnp.Domain", "a.b.c");
    device->SetAttribute("Upnp.Type", "test4");
    device->SetAttribute("Upnp.Version", "1");
    device->SetAttribute("Upnp.FriendlyName", (const TChar*)gNameDevice1_2.Ptr());
    AddService(device, new DviService(aDvStack, "a.b.c", "service4", 1));
    device->SetEnabled();
    iDevices[0]->SetEnabled();

    device = new DviDeviceStandard(aDvStack, Brn(gNameDevice2));
    iDevices[1] = device;
    device->SetAttribute("Upnp.Domain", "a.b.c");
    device->SetAttribute("Upnp.Type", "test2");
    device->SetAttribute("Upnp.Version", "1");
    device->SetAttribute("Upnp.FriendlyName", (const TChar*)gNameDevice2.Ptr());
    AddService(device, new DviService(aDvStack, "a.b.c", "service1", 1));
    AddService(device, new DviService(aDvStack, "a.b.c", "service2", 1));
    iDevices[1]->SetEnabled();
}
Exemple #4
0
SsdpNotifier::SsdpNotifier(DvStack& aDvStack)
    : iDvStack(aDvStack)
    , iSocket(aDvStack.Env())
    , iSocketWriter(iSocket, Endpoint(Ssdp::kMulticastPort, Ssdp::kMulticastAddress))
    , iBuffer(iSocketWriter)
    , iWriter(iBuffer)
    , iConfigId(0)
{
}
Exemple #5
0
DviService::DviService(DvStack& aDvStack, const TChar* aDomain, const TChar* aName, TUint aVersion)
    : Service(aDvStack.Env(), aDomain, aName, aVersion)
    , iDvStack(aDvStack)
    , iLock("DVSM")
    , iRefCount(1)
    , iPropertiesLock("SPRM")
    , iDisabled(true)
    , iCurrentInvocationCount(0)
    , iDisabledSem("DVSS", 0)
{
    iDisabledSem.Signal();
    iDvStack.Env().AddObject(this);
}
Exemple #6
0
DeviceBasic::DeviceBasic(DvStack& aDvStack)
{
    RandomiseUdn(aDvStack.Env(), gDeviceName);
    iDevice = new DvDevice(aDvStack, gDeviceName);
    iDevice->SetAttribute("Upnp.Domain", "openhome.org");
    iDevice->SetAttribute("Upnp.Type", "Test");
    iDevice->SetAttribute("Upnp.Version", "1");
    iDevice->SetAttribute("Upnp.FriendlyName", "ohNetTestDevice");
    iDevice->SetAttribute("Upnp.Manufacturer", "None");
    iDevice->SetAttribute("Upnp.ModelName", "ohNet test device");
    iTestBasic = new ProviderTestBasic(*iDevice);
    iDevice->SetEnabled();
}
Exemple #7
0
void TestDviDiscovery(DvStack& aDvStack)
{
    InitialisationParams* initParams = aDvStack.Env().InitParams();
    TUint oldMsearchTime = initParams->MsearchTimeSecs();
    initParams->SetMsearchTime(3); // higher time to give valgrind tests a hope of completing

    //Debug::SetLevel(Debug::kNetwork);
    Runner runner("SSDP discovery\n");
    runner.Add(new SuiteAlive(aDvStack));
    runner.Add(new SuiteMsearch(aDvStack));
    runner.Run();

    initParams->SetMsearchTime(oldMsearchTime);
}
Exemple #8
0
DviSubscriptionManager::DviSubscriptionManager(DvStack& aDvStack)
    : Thread("DVSM")
    , iDvStack(aDvStack)
    , iLock("DSBM")
    , iFree(aDvStack.Env().InitParams().DvNumPublisherThreads())
{
    const TUint numPublisherThreads = iDvStack.Env().InitParams().DvNumPublisherThreads();
    LOG(kDvEvent, "> DviSubscriptionManager: creating %u publisher threads\n", numPublisherThreads);
    TChar thName[5];
    iPublishers = (Publisher**)malloc(sizeof(*iPublishers) * numPublisherThreads);
    for (TUint i=0; i<numPublisherThreads; i++) {
        (void)sprintf(&thName[0], "DP%2lu", (unsigned long)i);
        iPublishers[i] = new Publisher(&thName[0], iFree);
        iFree.Write(iPublishers[i]);
        iPublishers[i]->Start();
    }
    Start();
}
Exemple #9
0
void TestDviDeviceList(CpStack& aCpStack, DvStack& aDvStack)
{
    InitialisationParams* initParams = aDvStack.Env().InitParams();
    TUint oldMsearchTime = initParams->MsearchTimeSecs();
    initParams->SetMsearchTime(1);

//    Debug::SetLevel(/*Debug::kDevice | Debug::kDvDevice | Debug::kXmlFetch | Debug::kError);

    Print("TestDviDeviceList - starting\n");

    DvDevices* devices = new DvDevices(aDvStack);
    CpDevices* deviceList = new CpDevices;
    FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &CpDevices::Added);
    FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &CpDevices::Removed);

    Print("Count devices implementing service1\n");
    Brn domainName("a.b.c");
    Brn serviceType("service1");
    TUint ver = 1;
    CpDeviceListUpnpServiceType* list =
                new CpDeviceListUpnpServiceType(aCpStack, domainName, serviceType, ver, added, removed);
    std::vector<const char*> udns;
    udns.push_back((const char*)gNameDevice1.Ptr());
    udns.push_back((const char*)gNameDevice2.Ptr());
    deviceList->Validate(udns);
    udns.clear();
    delete list;
    deviceList->Clear();

    Print("Count devices implementing service2\n");
    serviceType.Set("service2");
    list = new CpDeviceListUpnpServiceType(aCpStack, domainName, serviceType, ver, added, removed);
    udns.push_back((const char*)gNameDevice1_1.Ptr());
    udns.push_back((const char*)gNameDevice2.Ptr());
    deviceList->Validate(udns);
    udns.clear();
    delete list;

    delete deviceList;
    delete devices;

    Print("TestDviDeviceList - completed\n");
    initParams->SetMsearchTime(oldMsearchTime);
}
Exemple #10
0
DviSubscriptionManager::DviSubscriptionManager(DvStack& aDvStack)
    : Thread("DvSubscriptionMgr")
    , iDvStack(aDvStack)
    , iLock("DSBM")
    , iFree(aDvStack.Env().InitParams()->DvNumPublisherThreads())
{
    const TUint numPublisherThreads = iDvStack.Env().InitParams()->DvNumPublisherThreads();
    LOG(kDvEvent, "> DviSubscriptionManager: creating %u publisher threads\n", numPublisherThreads);
    iPublishers = (Publisher**)malloc(sizeof(*iPublishers) * numPublisherThreads);
    for (TUint i=0; i<numPublisherThreads; i++) {
        Bws<Thread::kMaxNameBytes+1> thName;
        thName.AppendPrintf("Publisher %d", i);
        thName.PtrZ();
        iPublishers[i] = new Publisher((const TChar*)thName.Ptr(), iFree);
        iFree.Write(iPublishers[i]);
        iPublishers[i]->Start();
    }
    Start();
}