return (offset);
}
-void
-Dhcpv4Srv::ifaceMgrSocket4ErrorHandler(const std::string& errmsg) {
- // Log the reason for socket opening failure and return.
- LOG_WARN(dhcp4_logger, DHCP4_OPEN_SOCKET_FAIL).arg(errmsg);
-}
-
void Dhcpv4Srv::classifyPacket(const Pkt4Ptr& pkt) {
boost::shared_ptr<OptionString> vendor_class =
boost::dynamic_pointer_cast<OptionString>(pkt->getOption(DHO_VENDOR_CLASS_IDENTIFIER));
/// @return Option that contains netmask information
static OptionPtr getNetmaskOption(const Subnet4Ptr& subnet);
- /// @brief Implements the error handler for socket open failure.
- ///
- /// This callback function is installed on the @c isc::dhcp::IfaceMgr
- /// when IPv4 sockets are being open. When socket fails to open for
- /// any reason, this function is called. It simply logs the error message.
- ///
- /// @param errmsg An error message containing a cause of the failure.
- static void ifaceMgrSocket4ErrorHandler(const std::string& errmsg);
-
/// @brief Allocation Engine.
/// Pointer to the allocation engine that we are currently using
/// It must be a pointer, because we will support changing engines
return (parser);
}
- /// @brief Determines if the given option space name and code describe
- /// a standard option for the DHCP4 server.
- ///
- /// @param option_space is the name of the option space to consider
- /// @param code is the numeric option code to consider
- /// @return returns true if the space and code are part of the server's
- /// standard options.
- bool isServerStdOption(std::string option_space, uint32_t code) {
- return ((option_space.compare("dhcp4") == 0)
- && LibDHCP::isStandardOption(Option::V4, code));
- }
-
- /// @brief Returns the option definition for a given option code from
- /// the DHCP4 server's standard set of options.
- /// @param code is the numeric option code of the desired option definition.
- /// @return returns a pointer the option definition
- OptionDefinitionPtr getServerStdOptionDefinition (uint32_t code) {
- return (LibDHCP::getOptionDef(Option::V4, code));
- }
-
/// @brief Issues a DHCP4 server specific warning regarding duplicate subnet
/// options.
///
return buffer4_receive_callout(callout_handle);
}
- /// Test callback that deletes MAC address
- /// @param callout_handle handle passed by the hooks framework
- /// @return always 0
- static int
- buffer4_receive_delete_hwaddr(CalloutHandle& callout_handle) {
-
- Pkt4Ptr pkt;
- callout_handle.getArgument("query4", pkt);
-
- pkt->data_[2] = 0; // offset 2 is hlen, let's set it to zero
- memset(&pkt->data_[28], 0, Pkt4::MAX_CHADDR_LEN); // Clear CHADDR content
-
- // carry on as usual
- return buffer4_receive_callout(callout_handle);
- }
-
/// Test callback that sets skip flag
/// @param callout_handle handle passed by the hooks framework
/// @return always 0
}
- // Test that the client message holding an FQDN is processed and
- // that the response packet is as expected.
- void testProcessMessageWithFqdn(const uint8_t msg_type,
- const std::string& hostname) {
- Pkt4Ptr req = generatePktWithFqdn(msg_type, Option4ClientFqdn::FLAG_S |
- Option4ClientFqdn::FLAG_E, hostname,
- Option4ClientFqdn::FULL, true);
- Pkt4Ptr reply;
- if (msg_type == DHCPDISCOVER) {
- ASSERT_NO_THROW(reply = srv_->processDiscover(req));
-
- } else if (msg_type == DHCPREQUEST) {
- ASSERT_NO_THROW(reply = srv_->processRequest(req));
-
- } else if (msg_type == DHCPRELEASE) {
- ASSERT_NO_THROW(srv_->processRelease(req));
- return;
-
- } else {
- return;
- }
-
- if (msg_type == DHCPDISCOVER) {
- checkResponse(reply, DHCPOFFER, 1234);
-
- } else {
- checkResponse(reply, DHCPACK, 1234);
- }
-
- }
-
// Verify that NameChangeRequest holds valid values.
void verifyNameChangeRequest(const isc::dhcp_ddns::NameChangeType type,
const bool reverse, const bool forward,
return (offset);
}
-void
-Dhcpv6Srv::ifaceMgrSocket6ErrorHandler(const std::string& errmsg) {
- // Log the reason for socket opening failure and return.
- LOG_WARN(dhcp6_logger, DHCP6_OPEN_SOCKET_FAIL).arg(errmsg);
-}
-
void Dhcpv6Srv::classifyPacket(const Pkt6Ptr& pkt) {
OptionVendorClassPtr vclass = boost::dynamic_pointer_cast<
OptionVendorClass>(pkt->getOption(D6O_VENDOR_CLASS));
private:
- /// @brief Implements the error handler for socket open failure.
- ///
- /// This callback function is installed on the @c isc::dhcp::IfaceMgr
- /// when IPv6 sockets are being open. When socket fails to open for
- /// any reason, this function is called. It simply logs the error message.
- ///
- /// @param errmsg An error message containing a cause of the failure.
- static void ifaceMgrSocket6ErrorHandler(const std::string& errmsg);
-
/// @brief Generate FQDN to be sent to a client if none exists.
///
/// This function is meant to be called by the functions which process
return (parser);
}
-
- /// @brief Determines if the given option space name and code describe
- /// a standard option for the DHCP6 server.
- ///
- /// @param option_space is the name of the option space to consider
- /// @param code is the numeric option code to consider
- /// @return returns true if the space and code are part of the server's
- /// standard options.
- bool isServerStdOption(std::string option_space, uint32_t code) {
- return ((option_space.compare("dhcp6") == 0)
- && LibDHCP::isStandardOption(Option::V6, code));
- }
-
- /// @brief Returns the option definition for a given option code from
- /// the DHCP6 server's standard set of options.
- /// @param code is the numeric option code of the desired option definition.
- /// @return returns a pointer the option definition
- OptionDefinitionPtr getServerStdOptionDefinition (uint32_t code) {
- return (LibDHCP::getOptionDef(Option::V6, code));
- }
-
/// @brief Issues a DHCP6 server specific warning regarding duplicate subnet
/// options.
///
/// Control-buffer, used in transmission and reception.
boost::scoped_array<char> control_buf_;
- /// @brief A wrapper for OS-specific operations before sending IPv4 packet
- ///
- /// @param m message header (will be later used for sendmsg() call)
- /// @param control_buf buffer to be used during transmission
- /// @param control_buf_len buffer length
- /// @param pkt packet to be sent
- void os_send4(struct msghdr& m, boost::scoped_array<char>& control_buf,
- size_t control_buf_len, const Pkt4Ptr& pkt);
-
- /// @brief OS-specific operations during IPv4 packet reception
- ///
- /// @param m message header (was used during recvmsg() call)
- /// @param pkt packet received (some fields will be set here)
- ///
- /// @return true if successful, false otherwise
- bool os_receive4(struct msghdr& m, Pkt4Ptr& pkt);
-
private:
/// @brief Identifies local network address to be used to
/// connect to remote address.
flag_broadcast_ = flags & IFF_BROADCAST;
}
-void IfaceMgr::os_send4(struct msghdr& /*m*/,
- boost::scoped_array<char>& /*control_buf*/,
- size_t /*control_buf_len*/,
- const Pkt4Ptr& /*pkt*/) {
- // @todo: Are there any specific actions required before sending IPv4 packet
- // on BSDs? See iface_mgr_linux.cc for working Linux implementation.
-}
-
-bool IfaceMgr::os_receive4(struct msghdr& /*m*/, Pkt4Ptr& /*pkt*/) {
- // @todo: Are there any specific actions required before receiving IPv4 packet
- // on BSDs? See iface_mgr_linux.cc for working Linux implementation.
-
- return (true); // pretend that we have everything set up for reception.
-}
-
void
IfaceMgr::setMatchingPacketFilter(const bool direct_response_desired) {
// If direct response is desired we have to use BPF. If the direct
}
}
-void IfaceMgr::os_send4(struct msghdr&, boost::scoped_array<char>&,
- size_t, const Pkt4Ptr&) {
- return;
-
-}
-
-bool IfaceMgr::os_receive4(struct msghdr&, Pkt4Ptr&) {
- return (true);
-}
-
bool
IfaceMgr::openMulticastSocket(Iface& iface,
const isc::asiolink::IOAddress& addr,
flag_broadcast_ = flags & IFF_BROADCAST;
}
-void IfaceMgr::os_send4(struct msghdr& /*m*/,
- boost::scoped_array<char>& /*control_buf*/,
- size_t /*control_buf_len*/,
- const Pkt4Ptr& /*pkt*/) {
- // @todo: Are there any specific actions required before sending IPv4 packet
- // on Solaris based systems? See iface_mgr_linux.cc
- // for working Linux implementation.
-}
-
-bool IfaceMgr::os_receive4(struct msghdr& /*m*/, Pkt4Ptr& /*pkt*/) {
- // @todo: Are there any specific actions required before receiving IPv4 packet
- // on BSDs? See iface_mgr_linux.cc for working Linux implementation.
-
- return (true); // pretend that we have everything set up for reception.
-}
-
void
IfaceMgr::setMatchingPacketFilter(const bool /* direct_response_desired */) {
// @todo Currently we ignore the preference to use direct traffic
virtual DhcpConfigParser* createSubnetConfigParser(
const std::string& config_id) = 0;
- /// @brief Determines if the given option space name and code describe
- /// a standard option for the server.
- ///
- /// @param option_space is the name of the option space to consider
- /// @param code is the numeric option code to consider
- /// @return returns true if the space and code are part of the server's
- /// standard options.
- virtual bool isServerStdOption(std::string option_space, uint32_t code) = 0;
-
- /// @brief Returns the option definition for a given option code from
- /// the server's standard set of options.
- /// @param code is the numeric option code of the desired option definition.
- /// @return returns a pointer the option definition
- virtual OptionDefinitionPtr getServerStdOptionDefinition (
- uint32_t code) = 0;
-
/// @brief Issues a server specific warning regarding duplicate subnet
/// options.
///
virtual ~D2ClientMgrTest(){
}
- /// @brief Updates the D2ClientMgr's configuration to DDNS disabled.
- void disableDdns() {
- D2ClientConfigPtr new_cfg;
- ASSERT_NO_THROW(new_cfg.reset(new D2ClientConfig()));
- ASSERT_NO_THROW(setD2ClientConfig(new_cfg));
- ASSERT_FALSE(ddnsEnabled());
- }
-
/// @brief Updates the D2ClientMgr's configuration to DDNS enabled.
///
/// @param server_address IP address of kea-dhcp-ddns.
public:
// Constructor - allocate file and create the specification object
- SpecificationForFileLogger() : spec_(), name_(createTempFileName()),
+ SpecificationForFileLogger() : spec_(), name_(createTempFilename()),
logname_("filelogger") {
// Set the output to a temporary file.
}
}
+void
+SignalSet::block() const {
+ maskSignals(SIG_BLOCK);
+}
+
void
SignalSet::clear() {
// Iterate over a copy of the registered signal set because the
}
}
+void
+SignalSet::unblock() const {
+ maskSignals(SIG_UNBLOCK);
+}
+
+
void
SignalSet::setOnReceiptHandler(BoolSignalHandler handler) {
onreceipt_handler_ = handler;
///
/// This function blocks the signals in a set to prevent race condition
/// between the signal handler and the new signal coming in.
- void block() const {
- maskSignals(SIG_BLOCK);
- }
+ void block() const;
/// @brief Removes the signal from the set.
///
/// @brief Unblocks signals in the set.
///
/// This function unblocks the signals in a set.
- void unblock() const {
- maskSignals(SIG_UNBLOCK);
- }
+ void unblock() const;
/// @brief Stores the set of signals registered in this signal set.
std::set<int> local_signals_;