1 /* doscan - Denial Of Service Capable Auditing of Networks -*- C++ -*- 2 * Copyright (C) 2003 Florian Weimer 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 // event_queue implementation using the epoll interface. 20 // DO NOT INCLUDE THIS FILE, use event_queue::create() instead. 21 22 #ifndef EVENT_QUEUE_EPOLL_H 23 #define EVENT_QUEUE_EPOLL_H 24 25 #include "event_queue.h" 26 27 #include <vector> 28 29 class event_queue_epoll : public event_queue { 30 unsigned count; 31 int epoll_fd; 32 33 // We have to keep track of "pending" file descriptors. These 34 // descriptors have been received from poll(), but we haven't 35 // dispatched them yet. Calls to unwatch() might reassign 36 // descriptors. 37 38 struct fd_activity { 39 fd_handler* fdh; 40 fd_handler::activity act; 41 }; 42 43 typedef std::vector<fd_activity> fd_activities_t; 44 fd_activities_t fd_activities; 45 46 void forget_activity(fd_handler*); 47 48 static unsigned convert_watch(fd_handler::watch_options); 49 50 protected: 51 virtual void add_fd(event_queue::fd_handler*, fd_handler::watch_options); 52 virtual void update_fd(event_queue::fd_handler*, fd_handler::watch_options); 53 virtual void remove_fd(event_queue::fd_handler*); 54 55 public: 56 event_queue_epoll(unsigned size_hint); 57 virtual ~event_queue_epoll(); 58 59 virtual void run(); 60 }; 61 62 #endif // EVENT_QUEUE_EPOLL_H 63