/* Test program for connection rules matching You provides rules in a file and you provide a rule on the command line. Enable --debug and --debugpath match and you will see the matching going on. */ #include #include #include #include #include #include #include #include static DEBUG_KEY D_MATCH("match","matching connection rules"); using namespace std; #include "connectrules.h" int main (int argc, char *argv[]) { glocal int ret = -1; glocal const char *fname = NULL; glocal.ret = (argc,argv); setproginfo ("","0.0","..."); setarg ('f',"fname","File to read",glocal.fname,true); int ret = -1; if (argc != 4){ usage(); }else{ glocal map > rules; (glocal.fname,true); vector tb; int n = str_splitline (line,' ',tb); if (n == 7){ glocal.rules[CONNECT_RULE_FROM(tb[0],tb[1],tb[2],tb[3])].push_back( CONNECT_RULE_TO(tb[4].c_str(),tb[5].c_str(),tb[6].c_str())); } return 0; CONNECT_RULE_FROM from (argv[0],argv[1],argv[2],argv[3]); map >::iterator found = blackhole_findmatch(from,glocal.rules); if (found == glocal.rules.end()){ printf ("No match\n"); }else{ printf ("found %s %s %s %s\n",found->first.master.c_str(),found->first.vserver.c_str() ,found->first.target.c_str(),found->first.dstport.c_str()); } ret = 0; } return ret; return glocal.ret; }