/* * ipqdemo.c by Alexander Demenshin * version 0.0a (very, very alpha :)) * * IPQ usage demonstration (very, very basic :) * * What it does? Nothing serious - only accept packets that are coming * from QUEUE target(s) and prints them out (not completely for now). * At least it may be usefult for beginners who have no where to start * playing with ip_queue :) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #ifndef __IPQ_H__ #define __IPQ_H__ #include #include #include #include #include #include #include #include #include #include #include //our headers #include "ddca.h" #include "router.h" /* * Normally, we should not expect that packets will be so big, * even including metadata, but who knows? :) */ #define MAX_PACKET_LEN 8192 #define UPDATE_SIGNAL SIGRTMIN + 5 // signal for update timer const int UPDATE_EXPIRE_SEC = 5L; const int UPDATE_EXPIRE_NSEC = 0L; class IPQ_HANDLER { private: struct ipq_handle *qh; struct ipq_packet_msg *qpkt; struct iphdr *iph; //unsigned char buff[sizeof *qpkt + MAX_PACKET_LEN]; unsigned char buff[MAX_PACKET_LEN]; int type; int len; // adding stuff for timer timer_t updateTimer; struct sigevent updateEvent; struct itimerspec updateSpec; struct sigaction sa; // used for registering handlers sigset_t set; siginfo_t info; public: struct ipq_handle * getHandler(){ return qh; } int initHandler(); void readPacket(); int handlePacket(); // timer management void initTimer (); void setTimer (); void cancelTimer (); void deleteTimer (); }; void startICRP(); #endif /*__IPQ_H__*/