diff options
author | Tomek Mrugalski <tomasz@isc.org> | 2011-11-29 19:15:17 +0100 |
---|---|---|
committer | Tomek Mrugalski <tomasz@isc.org> | 2011-11-29 19:15:17 +0100 |
commit | 537af1705fc5c1695b4b601571f65ead81dc1289 (patch) | |
tree | 85c8899bc78a323a7a90e4253cd0606fcbd177d0 /src/lib/dhcp/option4_addrlst.cc | |
parent | [1350] Support for DHCPv4 END option added. (diff) | |
download | kea-537af1705fc5c1695b4b601571f65ead81dc1289.tar.xz kea-537af1705fc5c1695b4b601571f65ead81dc1289.zip |
[1350] Changes after review:
- len() returns now uint16_t type
- using pre-increment intead of post-increment
- using distance() function
- moved some simple implementation to header
Diffstat (limited to 'src/lib/dhcp/option4_addrlst.cc')
-rw-r--r-- | src/lib/dhcp/option4_addrlst.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/lib/dhcp/option4_addrlst.cc b/src/lib/dhcp/option4_addrlst.cc index a5342c159b..88eb915427 100644 --- a/src/lib/dhcp/option4_addrlst.cc +++ b/src/lib/dhcp/option4_addrlst.cc @@ -42,10 +42,9 @@ Option4AddrLst::Option4AddrLst(uint8_t type, vector<uint8_t>::const_iterator first, vector<uint8_t>::const_iterator last) :Option(V4, type) { - vector<uint8_t> buf = std::vector<uint8_t>(first, last); - if ( (buf.size() % V4ADDRESS_LEN) ) { + if ( (distance(first, last) % V4ADDRESS_LEN) ) { isc_throw(OutOfRange, "DHCPv4 Option4AddrLst " << type_ - << " has invalid length=" << buf.size() + << " has invalid length=" << distance(first, last) << ", must be divisible by 4."); } @@ -79,7 +78,7 @@ Option4AddrLst::pack4(isc::util::OutputBuffer& buf) { while (addr != addrs_.end()) { buf.writeUint32(*addr); - addr++; + ++addr; } } @@ -112,8 +111,7 @@ void Option4AddrLst::addAddress(const isc::asiolink::IOAddress& addr) { addrs_.push_back(addr); } -unsigned short -Option4AddrLst::len() { +uint16_t Option4AddrLst::len() { // Returns length of the complete option (option header + data length) return (getHeaderLen() + addrs_.size() * V4ADDRESS_LEN); @@ -122,14 +120,15 @@ Option4AddrLst::len() { std::string Option4AddrLst::toText(int indent /* =0 */ ) { std::stringstream tmp; - for (int i = 0; i < indent; i++) + for (int i = 0; i < indent; i++) { tmp << " "; + } - tmp << "type=" << type_ << ", len=" << len()-getHeaderLen() << ": "; + tmp << "type=" << type_ << ", len=" << len()-getHeaderLen() << ":"; for (AddressContainer::const_iterator addr = addrs_.begin(); addr != addrs_.end(); ++addr) { - tmp << (*addr) << " "; + tmp << " " << (*addr); } return tmp.str(); |