Browse Source

[2902] Cleanup in comments.

Marcin Siodelski 12 years ago
parent
commit
8f8bfc92e6

+ 3 - 2
src/bin/dhcp4/dhcp4_srv.h

@@ -63,8 +63,9 @@ class Dhcpv4Srv : public boost::noncopyable {
     /// port on which DHCPv4 server will listen on. That is mostly useful
     /// for testing purposes. The Last two arguments of the constructor
     /// should be left at default values for normal server operation.
-    /// They should be disabled when creating an instance of this class
-    /// for unit testing as enabling them requires root privilegs.
+    /// They should be set to 'false' when creating an instance of this
+    /// class for unit testing because features they enable require
+    /// root privileges.
     ///
     /// @param port specifies port number to listen on
     /// @param dbconfig Lease manager configuration string.  The default

+ 1 - 1
src/lib/dhcp/hwaddr.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above

+ 11 - 9
src/lib/dhcp/iface_mgr.h

@@ -609,7 +609,7 @@ public:
     /// Packet Filters expose low-level functions handling sockets opening
     /// and sending/receiving packets through those sockets. This function
     /// sets custom Packet Filter (represented by a class derived from PktFilter)
-    /// to be used by IfaceMgr. Note that, there must be no IPv4 sockets
+    /// to be used by IfaceMgr. Note that there must be no IPv4 sockets open
     /// when this function is called. Call closeSockets(AF_INET) to close
     /// all hanging IPv4 sockets opened by the current packet filter object.
     ///
@@ -623,16 +623,18 @@ public:
     /// @brief Set Packet Filter object to handle send/receive packets.
     ///
     /// This function sets Packet Filter object to be used by IfaceMgr,
-    /// appropriate for the current OS. They will vary depending on the
-    /// OS being used if the function argument is set 'true'. There is
-    /// no guarantee that there is an implementation that supports this
-    /// feature on a particular OS. If there isn't the PktFilterInet
-    /// object will be set. If the argument is set to 'false' then
-    /// PktFilterInet object instance will be set as the Packet Filter
-    /// regrdaless of the OS.
+    /// appropriate for the current OS. Setting the argument to 'true'
+    /// indicates that function should set a packet filter class
+    /// which supports direct responses to clients having no address
+    /// assigned yet. Filters picked by this function will vary, depending
+    /// on the OS being used. There is no guarantee that there is an
+    /// implementation that supports this feature on a particular OS.
+    /// If there isn't, the PktFilterInet object will be set. If the
+    /// argument is set to 'false', PktFilterInet object instance will
+    /// be set as the Packet Filter regrdaless of the OS type.
     ///
     /// @param direct_response_desired specifies whether the Packet Filter
-    /// object being set should support direct responses to the host
+    /// object being set should support direct traffic to the host
     /// not having address assigned.
     void setMatchingPacketFilter(const bool direct_response_desired = false);
 

+ 2 - 0
src/lib/dhcp/iface_mgr_bsd.cc

@@ -52,6 +52,8 @@ bool IfaceMgr::os_receive4(struct msghdr& /*m*/, Pkt4Ptr& /*pkt*/) {
 
 void
 IfaceMgr::setMatchingPacketFilter(const bool /* direct_response_desired */) {
+    // @todo Currently we ignore the preference to use direct traffic
+    // because it hasn't been implemented for BSD systems.
     boost::shared_ptr<PktFilter> pkt_filter(new PktFilterInet());
     setPacketFilter(pkt_filter);
 }

+ 2 - 0
src/lib/dhcp/iface_mgr_sun.cc

@@ -52,6 +52,8 @@ bool IfaceMgr::os_receive4(struct msghdr& /*m*/, Pkt4Ptr& /*pkt*/) {
 
 void
 IfaceMgr::setMatchingPacketFilter(const bool /* direct_response_desired */) {
+    // @todo Currently we ignore the preference to use direct traffic
+    // because it hasn't been implemented for Solaris.
     boost::shared_ptr<PktFilter> pkt_filter(new PktFilterInet());
     setPacketFilter(pkt_filter);
 }

+ 27 - 21
src/lib/dhcp/pkt_filter_lpf.cc

@@ -27,38 +27,44 @@
 namespace {
 
 /// Socket filter program, used to filter out all traffic other
-/// then DHCP. In particular, it allows UDP packets on a specific
-/// (customizable) port. It does not allow fragmented packets.
+/// then DHCP. In particular, it allows receipt of UDP packets
+/// on a specific (customizable) port. It does not allow fragmented
+/// packets.
+///
+/// Socket filter program is platform independent code which is
+/// executed on the kernel level when new packet arrives. This concept
+/// origins from the Berkeley Packet Filtering supported on BSD systems.
+///
 /// @todo We may want to extend the filter to receive packets sent
 /// to the particular IP address assigned to the interface or
 /// broadcast address.
 struct sock_filter dhcp_sock_filter [] = {
-	// Make sure this is an IP packet...
-	BPF_STMT (BPF_LD + BPF_H + BPF_ABS, 12),
-	BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8),
+    // Make sure this is an IP packet...
+    BPF_STMT (BPF_LD + BPF_H + BPF_ABS, 12),
+    BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8),
 
-	// Make sure it's a UDP packet...
-	BPF_STMT (BPF_LD + BPF_B + BPF_ABS, 23),
-	BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 6),
+    // Make sure it's a UDP packet...
+    BPF_STMT (BPF_LD + BPF_B + BPF_ABS, 23),
+    BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 6),
 
-	// Make sure this isn't a fragment...
-	BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20),
-	BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 4, 0),
+    // Make sure this isn't a fragment...
+    BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20),
+    BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 4, 0),
 
-	// Get the IP header length...
-	BPF_STMT (BPF_LDX + BPF_B + BPF_MSH, 14),
+    // Get the IP header length...
+    BPF_STMT (BPF_LDX + BPF_B + BPF_MSH, 14),
 
-	// Make sure it's to the right port...
-	BPF_STMT (BPF_LD + BPF_H + BPF_IND, 16),
+    // Make sure it's to the right port...
+    BPF_STMT (BPF_LD + BPF_H + BPF_IND, 16),
     // Use default DHCP server port, but it can be
     // replaced if neccessary.
-	BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, isc::dhcp::DHCP4_SERVER_PORT, 0, 1),
+    BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, isc::dhcp::DHCP4_SERVER_PORT, 0, 1),
 
-	// If we passed all the tests, ask for the whole packet.
-	BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
+    // If we passed all the tests, ask for the whole packet.
+    BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
 
-	// Otherwise, drop it.
-	BPF_STMT(BPF_RET+BPF_K, 0),
+    // Otherwise, drop it.
+    BPF_STMT(BPF_RET+BPF_K, 0),
 };
 
 }
@@ -171,7 +177,7 @@ PktFilterLPF::send(const Iface& iface, uint16_t sockfd, const Pkt4Ptr& pkt) {
 
     // Ethernet frame header.
     // Note that we don't validate whether HW addresses in 'pkt'
-    // are valid because they are validated be the function called.
+    // are valid because they are checked by the function called.
     writeEthernetHeader(pkt, buf);
 
     // It is likely that the local address in pkt object is set to

+ 0 - 14
src/lib/dhcp/pkt_filter_lpf.h

@@ -77,20 +77,6 @@ public:
     virtual int send(const Iface& iface, uint16_t sockfd,
                      const Pkt4Ptr& pkt);
 
-protected:
-
-    static void assembleEthernetHeader(const Iface& iface,
-                                       const Pkt4Ptr& pkt,
-                                       util::OutputBuffer& out_buf);
-
-    static void assembleIpUdpHeader(const Pkt4Ptr& pkt,
-                                    util::OutputBuffer& out_buf);
-
-    static uint16_t checksum(const char* buf, const uint32_t buf_size,
-                             uint32_t sum = 0);
-
-    static uint16_t checksumFinish(uint16_t sum);
-    
 };
 
 } // namespace isc::dhcp