Statistics
| Branch: | Tag: | Revision:

one / include / AddressRangeIPAM.h @ 1772a358

History | View | Annotate | Download (2.93 KB)

1
/* -------------------------------------------------------------------------- */
2
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems                */
3
/*                                                                            */
4
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
5
/* not use this file except in compliance with the License. You may obtain    */
6
/* a copy of the License at                                                   */
7
/*                                                                            */
8
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
9
/*                                                                            */
10
/* Unless required by applicable law or agreed to in writing, software        */
11
/* distributed under the License is distributed on an "AS IS" BASIS,          */
12
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
13
/* See the License for the specific language governing permissions and        */
14
/* limitations under the License.                                             */
15
/* -------------------------------------------------------------------------- */
16

    
17
#ifndef ADDRESS_RANGE_IPAM_H_
18
#define ADDRESS_RANGE_IPAM_H_
19

    
20
#include <string>
21

    
22
#include "AddressRange.h"
23
#include "AddressRangePool.h"
24

    
25
class VectorAttribute;
26

    
27
class AddressRangeIPAM : public AddressRange
28
{
29
public:
30
    AddressRangeIPAM(unsigned int _id):AddressRange(_id){};
31

    
32
    virtual ~AddressRangeIPAM(){};
33

    
34
    /* ---------------------------------------------------------------------- */
35
    /* AddressRange Interface                                                 */
36
    /* ---------------------------------------------------------------------- */
37
    /**
38
     *  Init an Address Range based on a vector attribute.
39
     *    @param attr the description of the AddressRange
40
     *    @param error_msg description if error
41
     *    @return 0 on success
42
     */
43
    int from_vattr(VectorAttribute * attr, std::string& error_msg);
44

    
45
    /**
46
     *  Sets the given range of addresses (by index) as used
47
     *    @param index the first address to set as used
48
     *    @param sz number of addresses to set
49
     *    @param msg describing the error if any
50
     *
51
     *    @return 0 if success
52
     */
53
    int allocate_addr(unsigned int index, unsigned int rsize, string& error_msg);
54

    
55
    /**
56
     *  Gets a range of free addresses
57
     *    @param index the first address in the range
58
     *    @param size number of addresses requested in the range
59
     *    @param msg describing the error if any
60
     *
61
     *    @return 0 if success
62
     */
63
    int get_addr(unsigned int& index, unsigned int rsize, string& error_msg);
64

    
65
    /**
66
     *  Sets the given address (by index) as free
67
     *    @param index of the address
68
     *    @param msg describing the error if any
69
     *
70
     *    @return 0 if success
71
     */
72
    int free_addr(unsigned int index, string& msg);
73
};
74

    
75
#endif