Revision 1772a358 src/vnm/AddressRange.cc

View differences:

src/vnm/AddressRange.cc
388 388
/* -------------------------------------------------------------------------- */
389 389
/* -------------------------------------------------------------------------- */
390 390

  
391
void AddressRange::addr_to_xml(unsigned int index, unsigned int rsize,
392
        ostringstream& oss) const
393
{
394
    unsigned int new_mac[2];
395
    string       ip6_s;
396

  
397
    new_mac[0] = mac[0] + index;
398
    new_mac[1] = mac[1];
399

  
400
    oss << "<ADDRESS>"
401
        << "<MAC>" << mac_to_s(new_mac) << "</MAC>";
402

  
403
    if ( ip != 0 )
404
    {
405
        oss << "<IP>" << ip_to_s(ip + index) << "</IP>";
406
    }
407

  
408
    if (ula6[1] != 0 || ula6[0] != 0 )
409
    {
410
        oss << "<IP6_ULA>" << ip6_to_s(ula6, new_mac, ip6_s) << "</IP6_ULA>";
411
    }
412

  
413
    if (global6[1] != 0 || global6[0] != 0)
414
    {
415
        oss << "<IP6_GLOBAL>" << ip6_to_s(global6, new_mac, ip6_s)
416
            << "</IP6_GLOBAL>";
417
    }
418

  
419
    oss << "<SIZE>" << rsize << "</SIZE>"
420
        << "</ADDRESS>";
421
}
422

  
423
/* -------------------------------------------------------------------------- */
424
/* -------------------------------------------------------------------------- */
425

  
426
void AddressRange::to_xml(ostringstream &oss) const
427
{
428
    const map<string,string>& ar_attrs = attr->value();
429
    map<string,string>::const_iterator it;
430

  
431
    string       aux_st;
432
    unsigned int mac_end[2];
433

  
434
    oss << "<AR>";
435

  
436
    for (it=ar_attrs.begin(); it != ar_attrs.end(); it++)
437
    {
438
        if ( it->first == "ALLOCATED" )
439
        {
440
            continue;
441
        }
442

  
443
        oss << "<" << it->first << ">"
444
            << one_util::escape_xml(it->second)
445
            << "</"<< it->first << ">";
446
    }
447

  
448
    mac_end[1] = mac[1];
449
    mac_end[0] = (mac[0] + size - 1);
450

  
451
    oss << "<MAC_END>" << one_util::escape_xml(mac_to_s(mac_end))<<"</MAC_END>";
452

  
453
    aux_st = attr->vector_value("IP");
454

  
455
    if (aux_st != "")
456
    {
457
        unsigned int ip_i;
458

  
459
        if (ip_to_i(aux_st, ip_i) == 0)
460
        {
461
            oss << "<IP_END>" << one_util::escape_xml(ip_to_s(ip_i + size - 1))
462
                << "</IP_END>";
463
        }
464
    }
465

  
466
    if (type & 0x00000004)
467
    {
468
        string ip6_s;
469

  
470
        if (ula6[1] != 0 || ula6[0] != 0 )
471
        {
472
            ip6_to_s(ula6, mac, ip6_s);
473
            oss << "<IP6_ULA>" << one_util::escape_xml(ip6_s) << "</IP6_ULA>";
474

  
475
            ip6_to_s(ula6, mac_end, ip6_s);
476
            oss << "<IP6_ULA_END>" << one_util::escape_xml(ip6_s)
477
                << "</IP6_ULA_END>";
478
        }
479

  
480
        if (global6[1] != 0 || global6[0] != 0 )
481
        {
482
            ip6_to_s(global6, mac, ip6_s);
483
            oss << "<IP6_GLOBAL>" << one_util::escape_xml(ip6_s)
484
                << "</IP6_GLOBAL>";
485

  
486
            ip6_to_s(global6, mac_end, ip6_s);
487
            oss << "<IP6_GLOBAL_END>" << one_util::escape_xml(ip6_s)
488
                << "</IP6_GLOBAL_END>";
489
        }
490
    }
491

  
492
    oss << "<USED_LEASES>" << get_used_addr() << "</USED_LEASES>";
493
    oss << "</AR>";
494
}
495

  
496
/* -------------------------------------------------------------------------- */
497
/* -------------------------------------------------------------------------- */
498

  
391 499
void AddressRange::to_xml(ostringstream &oss, const vector<int>& vms,
392 500
        const vector<int>& vns, const vector<int>& vrs) const
393 501
{

Also available in: Unified diff