]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3715] Use foreach to iterate over IfaceMgr callbacks.
authorMarcin Siodelski <marcin@isc.org>
Fri, 13 Mar 2015 10:31:34 +0000 (11:31 +0100)
committerMarcin Siodelski <marcin@isc.org>
Fri, 13 Mar 2015 10:31:34 +0000 (11:31 +0100)
src/lib/dhcp/iface_mgr.cc

index f904cfce1a312bc9f61f37fcff20855b4a2bf947..a709bab87576508aa981e8c896cac512a27d864c 100644 (file)
@@ -292,13 +292,11 @@ IfaceMgr::isDirectResponseSupported() const {
 
 void
 IfaceMgr::addExternalSocket(int socketfd, SocketCallback callback) {
-    for (SocketCallbackInfoContainer::iterator s = callbacks_.begin();
-         s != callbacks_.end(); ++s) {
-
+    BOOST_FOREACH(SocketCallbackInfo s, callbacks_) {
         // There's such a socket description there already.
         // Update the callback and we're done
-        if (s->socket_ == socketfd) {
-            s->callback_ = callback;
+        if (s.socket_ == socketfd) {
+            s.callback_ = callback;
             return;
         }
     }
@@ -909,11 +907,10 @@ IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) {
 
     // if there are any callbacks for external sockets registered...
     if (!callbacks_.empty()) {
-        for (SocketCallbackInfoContainer::const_iterator s = callbacks_.begin();
-             s != callbacks_.end(); ++s) {
-            FD_SET(s->socket_, &sockets);
-            if (maxfd < s->socket_) {
-                maxfd = s->socket_;
+        BOOST_FOREACH(SocketCallbackInfo s, callbacks_) {
+            FD_SET(s.socket_, &sockets);
+            if (maxfd < s.socket_) {
+                maxfd = s.socket_;
             }
         }
     }
@@ -944,9 +941,8 @@ IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) {
     }
 
     // Let's find out which socket has the data
-    for (SocketCallbackInfoContainer::iterator s = callbacks_.begin();
-         s != callbacks_.end(); ++s) {
-        if (!FD_ISSET(s->socket_, &sockets)) {
+    BOOST_FOREACH(SocketCallbackInfo s, callbacks_) {
+        if (!FD_ISSET(s.socket_, &sockets)) {
             continue;
         }
 
@@ -955,8 +951,8 @@ IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) {
         // Calling the external socket's callback provides its service
         // layer access without integrating any specific features
         // in IfaceMgr
-        if (s->callback_) {
-            s->callback_();
+        if (s.callback_) {
+            s.callback_();
         }
 
         return (Pkt4Ptr());
@@ -1017,13 +1013,11 @@ Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */
 
     // if there are any callbacks for external sockets registered...
     if (!callbacks_.empty()) {
-        for (SocketCallbackInfoContainer::const_iterator s = callbacks_.begin();
-             s != callbacks_.end(); ++s) {
-
+        BOOST_FOREACH(SocketCallbackInfo s, callbacks_) {
             // Add it to the set as well
-            FD_SET(s->socket_, &sockets);
-            if (maxfd < s->socket_) {
-                maxfd = s->socket_;
+            FD_SET(s.socket_, &sockets);
+            if (maxfd < s.socket_) {
+                maxfd = s.socket_;
             }
         }
     }
@@ -1054,9 +1048,8 @@ Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */
     }
 
     // Let's find out which socket has the data
-    for (SocketCallbackInfoContainer::iterator s = callbacks_.begin();
-         s != callbacks_.end(); ++s) {
-        if (!FD_ISSET(s->socket_, &sockets)) {
+    BOOST_FOREACH(SocketCallbackInfo s, callbacks_) {
+        if (!FD_ISSET(s.socket_, &sockets)) {
             continue;
         }
 
@@ -1065,8 +1058,8 @@ Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */
         // Calling the external socket's callback provides its service
         // layer access without integrating any specific features
         // in IfaceMgr
-        if (s->callback_) {
-            s->callback_();
+        if (s.callback_) {
+            s.callback_();
         }
 
         return (Pkt6Ptr());