Browse Source

[991] Added skeleton of PktFilterLPF class.

Marcin Siodelski 12 years ago
parent
commit
2630be5587
3 changed files with 27 additions and 11 deletions
  1. 1 0
      src/lib/dhcp/Makefile.am
  2. 13 3
      src/lib/dhcp/pkt_filter_lpf.cc
  3. 13 8
      src/lib/dhcp/pkt_filter_lpf.h

+ 1 - 0
src/lib/dhcp/Makefile.am

@@ -37,6 +37,7 @@ libb10_dhcp___la_SOURCES += pkt6.cc pkt6.h
 libb10_dhcp___la_SOURCES += pkt4.cc pkt4.h
 libb10_dhcp___la_SOURCES += pkt_filter.h
 libb10_dhcp___la_SOURCES += pkt_filter_inet.cc pkt_filter_inet.h
+libb10_dhcp___la_SOURCES += pkt_filter_lpf.cc pkt_filter_lpf.h
 libb10_dhcp___la_SOURCES += std_option_defs.h
 
 libb10_dhcp___la_CXXFLAGS = $(AM_CXXFLAGS)

+ 13 - 3
src/lib/dhcp/pkt_filter_lpf.cc

@@ -21,13 +21,23 @@ namespace isc {
 namespace dhcp {
 
 int
-PktFilterLPF::openSocket(const std::string& ifname, const isc::asiolink::IOAddress& addr,
-                          const uint16_t port, const bool receive_bcast,
-                          const bool send_bcast) {
+PktFilterLPF::openSocket(const Iface&, const isc::asiolink::IOAddress&,
+                         const uint16_t, const bool,
+                         const bool) {
 
     return (-1);
 }
 
+Pkt4Ptr
+PktFilterLPF::receive(const Iface&, const SocketInfo&) {
+    return (Pkt4Ptr());
+}
+
+int
+PktFilterLPF::send(uint16_t, const Pkt4Ptr&) {
+    return (-1);
+}
+
 
 } // end of isc::dhcp namespace
 } // end of isc namespace

+ 13 - 8
src/lib/dhcp/pkt_filter_lpf.h

@@ -29,14 +29,14 @@ public:
 
     /// @brief Open socket.
     ///
-    /// @param interface name
+    /// @param iface interface descriptor
     /// @param addr address on the interface to be used to send packets.
     /// @param port port number.
     /// @param receive_bcast configure socket to receive broadcast messages
     /// @param send_bcast configure socket to send broadcast messages.
     ///
     /// @return created socket's descriptor
-    virtual int openSocket(const std::string& ifname,
+    virtual int openSocket(const Iface& iface,
                            const isc::asiolink::IOAddress& addr,
                            const uint16_t port,
                            const bool receive_bcast,
@@ -44,15 +44,20 @@ public:
 
     /// @brief Receive packet over specified socket.
     ///
-    /// @param sockfd descriptor of a socket to be used for packet reception
-    /// @param timeout_sec integral part of a timeout.
-    /// @param timeout_usec fractional part of a timeout (in microseconds).
+    /// @param iface interface
+    /// @param socket_info structure holding socket information
     ///
     /// @return Received packet
-    Pkt4Ptr receive(uint16_t sockfd, uint32_t timeout_sec,
-                    uint32_t timeout_usec = 0);
+    virtual Pkt4Ptr receive(const Iface& iface, const SocketInfo& socket_info);
+
+    /// @brief Send packet over specified socket.
+    ///
+    /// @param sockfd socket descriptor
+    /// @param pkt packet to be sent
+    ///
+    /// @return result of sending a packet. It is 0 if successful.
+    virtual int send(uint16_t sockfd, const Pkt4Ptr& pkt);
 
-    //    bool send(const Pkt4Ptr& pkt) = 0;
 };
 
 } // namespace isc::dhcp