#include #include #include #include #include #include #include class DDCA machine; class ROUTER ra; int main (int argc, char **argv) { //int addr = 0; if( argc < 3) { printf("Usage: ddca \n"); return 0; } else { machine.alpha = atoi(argv[1]); machine.t = atoi(argv[2]); } // machine.initDDCA (); // stuff added by axg for testing if(getuid() != 0 && geteuid() != 0) { cerr <<"You MUST be ROOT to execute this program" << endl; return 0; } //must call the set functions right here machine.setRouter(&ra); ra.setDDCA(&machine); ra.initRouting (); machine.initDDCA(); machine.initRAW(); // /* //use this section to check that the operations of the //routing table are working fine. RTEntry rt; rt.nid = inet_addr("1.1.1.1"); ra.insertEntry(&rt); rt.nid = inet_addr("2.2.2.2"); ra.insertEntry(&rt); ra.printTable(); if(ra.existEntry(&rt) != NULL) cerr <<"entry exists" << endl; rt.nid = inet_addr("1.1.1.1"); ra.deleteEntry(&rt); if(ra.existEntry(&rt) != NULL) cerr <<"entry exists" << endl; else cerr << "Entry does not exist" << endl; ra.printTable(); */ //checking the broadcast of new child /* RTEntry rt; rt.nid = inet_addr("1.1.1.1"); while(1) { ra.bcastNewChild(rt); sleep(1); } */ machine.enterInactive(); /******************************************************************************* Program 2: fork() and go on another way... *******************************************************************************/ if( fork() == 0) { //we are the child //we must start the ICRP... startICRP(); // system("./ipq"); return 2; //hihi, we have to tell that we are different from the ddca } machine.ddcaMain (); return 0; }