00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef ns_classifier_mcast_h
00024 #define ns_classifier_mcast_h
00025
00026 #include <stdlib.h>
00027 #include "config.h"
00028 #include "packet.h"
00029 #include "ip.h"
00030 #include "classifier.h"
00031
00032 class MCastClassifier : public Classifier {
00033 public:
00034 MCastClassifier();
00035 ~MCastClassifier();
00036 static const char STARSYM[];
00037 protected:
00038 virtual int command(int argc, const char*const* argv);
00039 virtual int classify(Packet *p);
00040 int findslot();
00041 enum {HASHSIZE = 256};
00042 struct hashnode {
00043 int slot;
00044 nsaddr_t src;
00045 nsaddr_t dst;
00046 hashnode* next;
00047 int iif;
00048 };
00049 int hash(nsaddr_t src, nsaddr_t dst) const {
00050 u_int32_t s = src ^ dst;
00051 s ^= s >> 16;
00052 s ^= s >> 8;
00053 return (s & 0xff);
00054 }
00055 hashnode* ht_[HASHSIZE];
00056 hashnode* ht_star_[HASHSIZE];
00057
00058 void set_hash(hashnode* ht[], nsaddr_t src, nsaddr_t dst,
00059 int slot, int iface);
00060 void clearAll();
00061 void clearHash(hashnode* h[], int size);
00062 hashnode* lookup(nsaddr_t src, nsaddr_t dst,
00063 int iface = iface_literal::ANY_IFACE) const;
00064 hashnode* lookup_star(nsaddr_t dst,
00065 int iface = iface_literal::ANY_IFACE) const;
00066 void change_iface(nsaddr_t src, nsaddr_t dst,
00067 int oldiface, int newiface);
00068 void change_iface(nsaddr_t dst,
00069 int oldiface, int newiface);
00070 };
00071 #endif