/// should be served. In particular, a lease is selected and sent
/// as an offer to a client if it should be served.
///
- /// @param solicit DISCOVER message received from client
+ /// @param discover DISCOVER message received from client
///
/// @return OFFER message or NULL
boost::shared_ptr<Pkt4>
/// @brief Stub function that will handle incoming INFORM messages.
///
- /// @param infRequest message received from client
+ /// @param inform message received from client
boost::shared_ptr<Pkt4> processInform(boost::shared_ptr<Pkt4>& inform);
/// @brief Copies default parameters from client's to server's message
// XXX: we cannot simply construct the address in the initialization list,
// because we'd like to throw our own exception on failure.
-IOAddress::IOAddress(const string& address_str) {
+IOAddress::IOAddress(const std::string& address_str) {
asio::error_code err;
asio_address_ = ip::address::from_string(address_str, err);
if (err) {
}
}
-IOAddress::IOAddress(const ip::address& asio_address) :
+IOAddress::IOAddress(const asio::ip::address& asio_address) :
asio_address_(asio_address)
{}
using namespace isc::dhcp;
namespace isc {
+namespace dhcp {
/// IfaceMgr is a singleton implementation
IfaceMgr* IfaceMgr::instance_ = 0;
return (false);
}
-bool IfaceMgr::Iface::delSocket(uint16_t sockfd) {
+bool IfaceMgr::Iface::delSocket(int sockfd) {
list<SocketInfo>::iterator sock = sockets_.begin();
while (sock!=sockets_.end()) {
if (sock->sockfd_ == sockfd) {
}
-
+}
}
/// @brief Adds socket descriptor to an interface.
///
/// @param socket SocketInfo structure that describes socket.
- void addSocket(const SocketInfo& sock)
- { sockets_.push_back(sock); }
+ void addSocket(const SocketInfo& socket)
+ { sockets_.push_back(socket); }
/// @brief Closes socket.
///
/// Closes socket and removes corresponding SocketInfo structure
/// from an interface.
///
- /// @param socket descriptor to be closed/removed.
+ /// @param sockfd descriptor to be closed/removed.
/// @return true if there was such socket, false otherwise
- bool delSocket(uint16_t sockfd);
+ bool delSocket(int sockfd);
/// socket used to sending data
/// TODO: this should be protected
/// in options container.
///
/// @param buf Buffer to be parsed.
+ /// @param buf_len length of the buffer passed in buf.
/// @param offset Specifies offset for the first option.
+ /// @param parse_len length of buffer to be parsed.
/// @param options Reference to option container. Options will be
/// put here.
///
static unsigned int
unpackOptions6(const boost::shared_array<uint8_t> buf, unsigned int buf_len,
unsigned int offset, unsigned int parse_len,
- isc::dhcp::Option::OptionCollection& options_);
+ isc::dhcp::Option::OptionCollection& options);
- ///
/// Registers factory method that produces options of specific option types.
///
/// @param u universe of the option (V4 or V6)
- /// @param opt_type option-type
+ /// @param type option-type
/// @param factory function pointer
///
/// @return true, if registration was successful, false otherwise
- ///
static bool
OptionFactoryRegister(Option::Universe u,
- unsigned short type,
+ uint16_t type,
Option::Factory * factory);
protected:
// pointers to factories that produce DHCPv6 options
#include "dhcp/libdhcp++.h"
using namespace std;
-using namespace isc::dhcp;
using namespace isc::util;
+namespace isc {
+namespace dhcp {
+
Option::Option(Universe u, unsigned short type)
:universe_(u), type_(type) {
check();
}
-Option::Option(Universe u, uint16_t type, vector<uint8_t>::const_iterator first,
- vector<uint8_t>::const_iterator last)
+Option::Option(Universe u, uint16_t type, std::vector<uint8_t>::const_iterator first,
+ std::vector<uint8_t>::const_iterator last)
:universe_(u), type_(type), data_(std::vector<uint8_t>(first,last)) {
check();
}
Option::~Option() {
}
+
+} // end of isc::dhcp namespace
+} // end of isc namespace
/// @param buf buffer that contains raw buffer to parse (on-wire format)
/// @param buf_len buffer length (used for buffer overflow checks)
/// @param offset offset from start of the buf buffer
+ /// @param parse_len number of bytes to be parsed.
///
/// @return offset to the next byte after last parsed byte
virtual unsigned int
/// @param buf buffer that contains raw buffer to parse (on-wire format)
/// @param buf_len buffer length (used for buffer overflow checks)
/// @param offset offset from start of the buf buffer
+ /// @param parse_len number of bytes to be parsed.
///
/// @return offset to the next byte after last parsed byte
virtual unsigned int
#include <dhcp/option4_addrlst.h>
using namespace std;
-using namespace isc::dhcp;
using namespace isc::util;
using namespace isc::asiolink;
+namespace isc {
+namespace dhcp {
+
Option4AddrLst::Option4AddrLst(uint8_t type)
:Option(V4, type) {
}
Option4AddrLst::Option4AddrLst(uint8_t type,
- vector<uint8_t>::const_iterator first,
- vector<uint8_t>::const_iterator last)
+ std::vector<uint8_t>::const_iterator first,
+ std::vector<uint8_t>::const_iterator last)
:Option(V4, type) {
if ( (distance(first, last) % V4ADDRESS_LEN) ) {
isc_throw(OutOfRange, "DHCPv4 Option4AddrLst " << type_
return tmp.str();
}
+
+} // end of isc::dhcp namespace
+} // end of isc namespace
using namespace std;
using namespace isc;
-using namespace isc::dhcp;
using namespace isc::util;
-Option6IA::Option6IA(unsigned short type, unsigned int iaid)
+namespace isc {
+namespace dhcp {
+
+Option6IA::Option6IA(uint16_t type, uint32_t iaid)
:Option(Option::V6, type), iaid_(iaid) {
}
-Option6IA::Option6IA(unsigned short type,
+Option6IA::Option6IA(uint16_t type,
const boost::shared_array<uint8_t>& buf,
unsigned int buf_len,
unsigned int offset,
}
return (length);
}
+
+} // end of isc::dhcp namespace
+} // end of isc namespace
///
/// @param type option type (usually 4 for IA_NA, 25 for IA_PD)
/// @param iaid identity association identifier (id of IA)
- Option6IA(uint16_t type, unsigned int iaid);
+ Option6IA(uint16_t type, uint32_t iaid);
/// @brief ctor, used for received options
///
///
/// @param type option type
/// @param buf pointer to a buffer
+ /// @param buf_len length of the buffer passed in buf
/// @param offset offset to first data byte in that buffer
/// @param len data length of this option
Option6IAAddr(unsigned short type, boost::shared_array<uint8_t> buf,
/// Sets sname field
///
/// @param sname value to be set
+ /// @param snameLen length of the buffer passed in sname
void
setSname(const uint8_t* sname, size_t snameLen = MAX_SNAME_LEN);
/// Sets file field
///
/// @param file value to be set
+ /// @param fileLen length of the buffer passed in file
void
setFile(const uint8_t* file, size_t fileLen = MAX_FILE_LEN);
///
/// Note: macAddr must be a buffer of at least hlen bytes.
///
- /// @param hwType hardware type (will be sent in htype field)
+ /// @param hType hardware type (will be sent in htype field)
/// @param hlen hardware length (will be sent in hlen field)
/// @param macAddr pointer to hardware address
void setHWAddr(uint8_t hType, uint8_t hlen,
/// @brief Sets remote address.
///
- /// @params remote specifies remote address
+ /// @param remote specifies remote address
void setRemoteAddr(const isc::asiolink::IOAddress& remote) {
remote_addr_ = remote;
}
/// @brief Sets local address.
///
- /// @params local specifies local address
+ /// @param local specifies local address
void setLocalAddr(const isc::asiolink::IOAddress& local) {
local_addr_ = local;
}
/// @brief Sets local port.
///
- /// @params local specifies local port
+ /// @param local specifies local port
void setLocalPort(uint16_t local) { local_port_ = local; }
/// @brief Returns local port.
/// @brief Sets remote port.
///
- /// @params remote specifies remote port
+ /// @param remote specifies remote port
void setRemotePort(uint16_t remote) { remote_port_ = remote; }
/// @brief Returns remote port.
using namespace isc::dhcp;
namespace isc {
+namespace dhcp {
Pkt6::Pkt6(unsigned int dataLen, DHCPv6Proto proto /* = UDP */)
:data_len_(dataLen),
}
Pkt6::Pkt6(uint8_t msg_type,
- unsigned int transid,
+ uint32_t transid,
DHCPv6Proto proto /*= UDP*/)
:local_addr_("::"),
remote_addr_("::"),
iface_(""),
ifindex_(-1),
- local_port_(-1),
- remote_port_(-1),
+ local_port_(0),
+ remote_port_(0),
proto_(proto),
msg_type_(msg_type),
transid_(transid) {
}
boost::shared_ptr<isc::dhcp::Option>
-Pkt6::getOption(unsigned short opt_type) {
+Pkt6::getOption(uint16_t opt_type) {
isc::dhcp::Option::OptionCollection::const_iterator x = options_.find(opt_type);
if (x!=options_.end()) {
return (*x).second;
}
bool
-Pkt6::delOption(unsigned short type) {
+Pkt6::delOption(uint16_t type) {
isc::dhcp::Option::OptionCollection::iterator x = options_.find(type);
if (x!=options_.end()) {
options_.erase(x);
return (false); // can't find option to be deleted
}
-};
+} // end of isc::dhcp namespace
+} // end of isc namespace
/// @param msg_type type of message (SOLICIT=1, ADVERTISE=2, ...)
/// @param transid transaction-id
/// @param proto protocol (TCP or UDP)
- Pkt6(unsigned char msg_type,
- unsigned int transid,
+ Pkt6(uint8_t msg_type,
+ uint32_t transid,
DHCPv6Proto proto = UDP);
/// Constructor, used in message transmission
/// Returns message type (e.g. 1 = SOLICIT)
///
/// @return message type
- unsigned char
+ uint8_t
getType() { return (msg_type_); }
/// Sets message type (e.g. 1 = SOLICIT)
///
/// @param type message type to be set
- void setType(unsigned char type) { msg_type_=type; };
+ void setType(uint8_t type) { msg_type_=type; };
/// Returns value of transaction-id field
///
/// @return transaction-id
- unsigned int getTransid() { return (transid_); };
+ uint32_t getTransid() { return (transid_); };
/// Adds an option to this packet.
///
/// instances of the same option are allowed (and frequently used).
/// See getOptions().
///
- /// @param opt_type option type we are looking for
+ /// @param type option type we are looking for
///
/// @return pointer to found option (or NULL)
boost::shared_ptr<isc::dhcp::Option>
- getOption(unsigned short type);
+ getOption(uint16_t type);
/// Attempts to delete first suboption of requested type
///
///
/// @return true if option was deleted, false if no such option existed
bool
- delOption(unsigned short type);
+ delOption(uint16_t type);
/// TODO need getter/setter wrappers
/// and hide following fields as protected
int ifindex_;
/// local TDP or UDP port
- int local_port_;
+ uint16_t local_port_;
/// remote TCP or UDP port
- int remote_port_;
+ uint16_t remote_port_;
/// TODO Need to implement getOptions() as well
DHCPv6Proto proto_;
/// DHCPv6 message type
- int msg_type_;
+ uint8_t msg_type_;
/// DHCPv6 transaction-id
- unsigned int transid_;
+ uint32_t transid_;
}; // Pkt6 class
} // isc::dhcp namespace
/// If specified buffer is too short, it will be expanded
/// using vector::resize() method.
///
- /// @param Reference to a buffer (data will be stored there).
- /// @param Size specified number of bytes to read in a vector.
- ///
+ /// @param data Reference to a buffer (data will be stored there).
+ /// @param len Size specified number of bytes to read in a vector.
void readVector(std::vector<uint8_t>& data, size_t len)
{
if (position_ + len > len_) {