Example #1
0
static void RandomiseUdn(Bwh& aUdn)
{
    aUdn.Grow(aUdn.Bytes() + 1 + Ascii::kMaxUintStringBytes + 1);
    aUdn.Append('-');
    Bws<Ascii::kMaxUintStringBytes> buf;
    NetworkInterface* nif = Stack::NetworkInterfaceList().CurrentInterface();
    TUint max = nif->Address();
    delete nif;
    (void)Ascii::AppendDec(buf, Random(max));
    aUdn.Append(buf);
    aUdn.PtrZ();
}
void OpenHome::TestFramework::RandomiseUdn(Environment& aEnv, Bwh& aUdn)
{
    aUdn.Grow(aUdn.Bytes() + 1 + Ascii::kMaxUintStringBytes + 1);
    aUdn.Append('-');
    Bws<Ascii::kMaxUintStringBytes> buf;
    std::vector<NetworkAdapter*>* subnetList = aEnv.NetworkAdapterList().CreateSubnetList();
    TUint max = (subnetList->size() > 0? (*subnetList)[0]->Address() : UINT_MAX);
    aEnv.NetworkAdapterList().DestroySubnetList(subnetList);
    (void)Ascii::AppendDec(buf, aEnv.Random(max));
    aUdn.Append(buf);
    aUdn.PtrZ();
}
Example #3
0
static void RandomiseUdn(Bwh& aUdn)
{
    aUdn.Grow(aUdn.Bytes() + 1 + Ascii::kMaxUintStringBytes + 1);
    aUdn.Append('-');
    Bws<Ascii::kMaxUintStringBytes> buf;
    std::vector<NetworkAdapter*>* subnetList = Stack::NetworkAdapterList().CreateSubnetList();
    TUint max = (*subnetList)[0]->Address();
    TUint seed = DviStack::ServerUpnp().Port((*subnetList)[0]->Address());
    SetRandomSeed(seed);
    Stack::NetworkAdapterList().DestroySubnetList(subnetList);
    (void)Ascii::AppendDec(buf, Random(max));
    aUdn.Append(buf);
    aUdn.PtrZ();
}
Example #4
0
static void RandomiseUdn(Bwh& aUdn)
{
    aUdn.Grow(aUdn.Bytes() + 1 + Ascii::kMaxUintStringBytes + 1);
    aUdn.Append('-');
    Bws<Ascii::kMaxUintStringBytes> buf;
    NetworkAdapter* nif = Stack::NetworkAdapterList().CurrentAdapter(kAdapterCookie);
    TUint max = nif->Address();
    TUint seed = DviStack::ServerUpnp().Port(nif->Address());
    SetRandomSeed(seed);
    nif->RemoveRef(kAdapterCookie);
    (void)Ascii::AppendDec(buf, Random(max));
    aUdn.Append(buf);
    aUdn.PtrZ();
}
Example #5
0
static void RandomiseUdn(std::string& aUdn)
{
    Bwh udn;
    udn.Grow((TUint)aUdn.length() + 1 + Ascii::kMaxUintStringBytes + 1);
    Brn buf((const TByte*)aUdn.c_str(), (TUint)aUdn.length());
    udn.Append(buf);
    udn.Append('-');
    Bws<Ascii::kMaxUintStringBytes> addr;
    std::vector<NetworkAdapter*>* subnetList = gEnv->NetworkAdapterList().CreateSubnetList();
    TUint max = (*subnetList)[0]->Address();
    TUint seed = gDvStack->ServerUpnp().Port((*subnetList)[0]->Address());
    SetRandomSeed(seed);
    gEnv->NetworkAdapterList().DestroySubnetList(subnetList);
    (void)Ascii::AppendDec(addr, Random(max));
    udn.Append(addr);
    udn.PtrZ();
    aUdn.assign((const char*)udn.Ptr(), udn.Bytes());
}