This commit is contained in:
Ren RenJuan 2014-01-13 23:19:10 +00:00
parent ddc9b4c179
commit 15404b4bcd
8 changed files with 143 additions and 61 deletions

Binary file not shown.

View File

@ -211,9 +211,12 @@ void setSignals() {
} }
void signal_handler(int sig) void signal_handler(int sig)
{ { int debug=0;
switch(sig) { switch(sig) {
case SIGSEGV: case SIGSEGV:
debug=1; // for breakpoint
theseLogs.logN(0,"Segfault great that you can see this.");
break; break;
case SIGUSR1: case SIGUSR1:
break; break;

View File

@ -1,6 +1,10 @@
#include <ncurses.h> #include <ncurses.h>
#include "ausreg-cd.h" #include "ausreg-cd.h"
#define ASSERT(expr) \
if (!(expr)) { \
std::cerr << __FILE__ << ":" << __LINE__ << ":" << #expr << std::endl;}
const char *banner = CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)"; const char *banner = CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)";
const char *cmdNames[9] = { "check", "info", "poll", "transfer query", const char *cmdNames[9] = { "check", "info", "poll", "transfer query",
"create", "renew", "update", "delete", "transfer" }; "create", "renew", "update", "delete", "transfer" };
@ -35,14 +39,19 @@ void mdCommander::doHeader() {
} }
void mdCommander::digestibleLines() { void mdCommander::digestibleLines() {
char *sp; char buffer[256],*sp;
int nLines=0, wrow=5; int nLines=0, wrow=5;
nocbreak(); nocbreak();
for (;argsNow[cmdNow] < MAX_CMD_ARGS;argsNow[cmdNow]++) for (;argsNow[cmdNow] < MAX_CMD_ARGS;)
{sp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(256); {memset(buffer,0,sizeof(buffer));
mvgetstr(wrow++,2,sp); mvgetstr(wrow++,2,buffer);
if (!strlen(sp)) break; if (strlen(buffer)) {
sp = (char *) malloc(strlen(buffer)+1);
commandArgs[cmdNow][argsNow[cmdNow]++] = sp;
strcpy(sp,buffer);
}
else break;
} }
cbreak(); cbreak();
prompt(false); prompt(false);
@ -160,6 +169,7 @@ void mdCommander::driver() {
cmdNow = --targetCmd; cmdNow = --targetCmd;
editingCommand(false); editingCommand(false);
doHeader();} doHeader();}
help();
break; break;
case 'S': case 'S':
if (isValidCmd(targetCmd,false)) { if (isValidCmd(targetCmd,false)) {
@ -318,6 +328,7 @@ void mdCommander::flushCommand(int which,bool allOfEm){
for (j=0;j<argsNow[i];j++) for (j=0;j<argsNow[i];j++)
free(commandArgs[i][j]); free(commandArgs[i][j]);
} }
else deleted[i] = false; // back to start state.
} }
cmdNow = 0; cmdNow = 0;
cmdsNow = 0; cmdsNow = 0;
@ -345,7 +356,9 @@ void mdCommander::showCommand(bool allOfEm){
sprintf(wwork,"EPP directive: %s",befehlJetzt); sprintf(wwork,"EPP directive: %s",befehlJetzt);
mvprintw(5,2,wwork); mvprintw(5,2,wwork);
for (nthItem=0;nthItem < argsNow[cmdNow];nthItem++) { for (nthItem=0;nthItem < argsNow[cmdNow];nthItem++) {
mvprintw(7+nthItem,2,(char *)commandArgs[cmdNow][nthItem]); ASSERT(commandArgs[cmdNow][nthItem]);
sprintf(wwork,"%d %s",nthItem+1,(commandArgs[cmdNow][nthItem]));
mvprintw(7+nthItem,2,wwork);
} }
} else { } else {
@ -354,8 +367,8 @@ void mdCommander::showCommand(bool allOfEm){
for ( i=0, nthItem=0; nthItem < cmdsNow;nthItem++ ) { for ( i=0, nthItem=0; nthItem < cmdsNow;nthItem++ ) {
if (!deleted[0]) { if (!deleted[nthItem]) {
sprintf(wwork,"%d %s %s",i+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]); sprintf(wwork,"%d %s %s",nthItem+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]);
mvprintw(7+(i++),2,wwork); mvprintw(7+(i++),2,wwork);
} }
@ -372,46 +385,47 @@ void mdCommander::showCommand(bool allOfEm){
bool mdCommander::editingCommand(bool run){ bool mdCommander::editingCommand(bool run){
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]]; const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
char *sp; char sp[256],*spp;
int editLine; int editLine,length;
bool editing=true;
doHeader(); doHeader();
mvprintw(3,(col-strlen(befehlJetzt))/2,befehlJetzt); mvprintw(3,(col-strlen(befehlJetzt))/2,befehlJetzt);
if (!run) { if (!run) {
if (!argsNow[cmdNow]) { if (!argsNow[cmdNow]) {
say((char *)"Enter strings for command or just enter to end data entry"); say((char *)"Enter command arg strings, just enter to end data entry, ? to main menu");
prompt(true); prompt(true);
digestibleLines(); digestibleLines();
} else { } else {
while(editing) { nocbreak();
say((char *)"<n> of arg to replace, A to add, -<n> to erase, just enter to finish"); while(true) {
showCommand(false);
say((char *)"line no to replace, A to add, enter to return");
prompt(false);
mvgetstr(row-1,2,sp);
if (!strlen(sp)) goto done;
if (*sp == 'A' || *sp == 'a') {
prompt(true); prompt(true);
mvgetstr(row-1,2,sp); mvgetstr(row-1,2,sp);
if (!strlen(sp)) editing = false; if (length=strlen(sp)) {
else { spp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(length+1);
if (*sp == 'A' || *sp == 'a') { strcpy(spp,sp);
if (strlen(sp)) {
sp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(256);
mvgetstr(row-1,2,sp);
} }
continue;
} }
if (is_numeric(sp) >= 1) {
editLine = atoi(sp); editLine = atoi(sp);
if (editLine>0) { if (editLine > 1 && editLine < argsNow[cmdNow]) {
prompt(true);
mvgetstr(row-1,2,sp); mvgetstr(row-1,2,sp);
if (strlen(sp)) { if (length=strlen(sp)) {
free (commandArgs[cmdNow][editLine]); free (commandArgs[cmdNow][editLine-1]);
commandArgs[cmdNow][editLine] = (char *) malloc(strlen(sp)+1); spp = commandArgs[cmdNow][editLine-1] = (char *) malloc(strlen(sp)+1);
strcpy(commandArgs[cmdNow][editLine],sp); strcpy(spp,sp);
} }
} }
else { editLine = editLine * -1 ;
memset(commandArgs[cmdNow][editLine],0,strlen(commandArgs[cmdNow][editLine]));
} }
} // editing body
} // editing loop } // editing loop
} // new / existing done: cbreak();
} // editing block
} // run / execute } // run / execute
else { else {
say((char *)"Press 'Y' to confirm"); say((char *)"Press 'Y' to confirm");
@ -423,62 +437,62 @@ void mdCommander::check(bool run) {
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 0; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 0;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
} }
void mdCommander::create(bool run){ void mdCommander::create(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 4; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 4;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
}; };
void mdCommander::info(bool run){ void mdCommander::info(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 1; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 1;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
}; };
void mdCommander::renew(bool run){ void mdCommander::renew(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 5; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 5;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
}; };
void mdCommander::queryTransfer(bool run){ void mdCommander::queryTransfer(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 3; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 3;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
}; };
void mdCommander::trash(bool run){ void mdCommander::trash(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 7; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 7;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
}; };
void mdCommander::transfer(bool run){ void mdCommander::transfer(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 8; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 8;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
}; };
void mdCommander::poll(bool run){ void mdCommander::poll(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 2; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 2;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
}; };
void mdCommander::update(bool run){ void mdCommander::update(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 6; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 6;
if (!editingCommand(run)) { if (!editingCommand(run)) {
} } else help();
}; };

View File

@ -8,7 +8,6 @@ class mdCommander {
bool acceptingInput,deleted[MAX_CMDS]; bool acceptingInput,deleted[MAX_CMDS];
bool EPPmode; // RFC 9 bool EPPmode; // RFC 9
int activeCommands, argsNow[MAX_CMDS], cmdNow, cmdsNow, mdStdDevIdx; int activeCommands, argsNow[MAX_CMDS], cmdNow, cmdsNow, mdStdDevIdx;
std::string currentDevice;
int row,col; int row,col;
int commandsNow[MAX_CMDS]; // type index into cmdNames int commandsNow[MAX_CMDS]; // type index into cmdNames
char *commandArgs[MAX_CMDS][MAX_CMD_ARGS]; char *commandArgs[MAX_CMDS][MAX_CMD_ARGS];
@ -16,7 +15,9 @@ class mdCommander {
public: public:
mdCommander() {mdStdDevIdx=0; cmdsNow=0; cmdNow = 0;} mdCommander() {mdStdDevIdx=0; cmdsNow=0; cmdNow = 0;
memset(commandArgs,0,sizeof(commandArgs));
}
~mdCommander() {} ~mdCommander() {}
void say(char *what) ; void say(char *what) ;

View File

@ -32,5 +32,6 @@ class ausRegEPPTK {
} }
bool didInit(const std::string propertiesFilePath); bool didInit(const std::string propertiesFilePath);
void doOTEA(); void doOTEA();
void doOTEB();
}; };

View File

@ -144,6 +144,9 @@ enum acTKScenario {
ACTK_ALONE = 0, ACTK_ALONE = 0,
ACTK_INSECURE, ACTK_INSECURE,
ACTK_OTEA, ACTK_OTEA,
ACTK_OTEB,
ACTK_OTEC,
ACTK_PROD,
N_ACTK_SCENARIOS N_ACTK_SCENARIOS
}; };

View File

@ -231,6 +231,18 @@ void oteA() {
} }
}void oteB() {
int nthDay;
for (nthDay=0;nthDay<30;nthDay++) {
theseLogs->logNdebug(MAX_DEBUG,1,"PreProd / OTEB day %d",nthDay);
thisService->artk->doOTEB();
theseLogs->logNdebug(MAX_DEBUG,1,"Preprod/ OTEB day %d",nthDay);
thisService->artk->daysRunning = nthDay;
}
} }
void masterDaemon::run() { void masterDaemon::run() {
@ -238,13 +250,17 @@ void masterDaemon::run() {
fg = new mdDGChannel( thisService->io_, 0 ); fg = new mdDGChannel( thisService->io_, 0 );
if (initAusRegTK()) return; if (initAusRegTK()) return;
else switch(artk->tkScenario) { if (artk->tkScenario == ACTK_OTEA) {
case ACTK_OTEA:
boost::thread oteArun(oteA); boost::thread oteArun(oteA);
assert(oteArun.joinable()); assert(oteArun.joinable());
oteArun.join(); oteArun.join();
theseLogs->logNdebug(MAX_DEBUG,0,"OTE Connectivity Test EOJ."); theseLogs->logNdebug(MAX_DEBUG,0,"OTE Connectivity Test EOJ.");
break; }
if (artk->tkScenario == ACTK_OTEB) {
boost::thread oteBrun(oteB);
assert(oteBrun.joinable());
oteBrun.join();
theseLogs->logNdebug(MAX_DEBUG,0,"Pre-production Ops / OTEB EOJ.");
} }
listen(); listen();
boost::thread work(mdWQ); boost::thread work(mdWQ);

View File

@ -30,6 +30,50 @@ bool ausRegEPPTK::didInit(const std::string propertiesFilePath) {
} }
void ausRegEPPTK::doOTEA() void ausRegEPPTK::doOTEA()
{
int hours,hoops;
string op("newInstance");
if (!daysRunning)
scenario(tkScenario);
try {
Timer::setTime("20070101.010101");
auto_ptr<SessionManager> manager(SessionManagerFactory::newInstance(&props));
auto_ptr<Session> sess(SessionFactory::newInstance(&props));
op = "startup";
manager->startup();
op = "run (keep-alive)";
manager->run();
sess->open();
for (hours=0;hours < 24;hours++) {
// Spawn the keep alive thread.
theseLogs->logN(1,"Send Test SEs on or about start OTE Test Hour %d.",hours);
for (hoops=0;hoops<7;hoops++) {
sess->writeXML(TEST_SE);
sess->read();
sleep(857);
}
}
sess->close();
manager->shutdown();
}
catch (EPPException& e)
{ const char *eMsg = e.getMessage().c_str();
const char *opNow = op.c_str();
theseLogs->logN(2,"EPP Exception during OTE A (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(2,"General Exception during OTE A (%s).",op.c_str());
}
}
void ausRegEPPTK::doOTEB()
{ {
int hours; int hours;
string op("newInstance"); string op("newInstance");
@ -51,7 +95,7 @@ void ausRegEPPTK::doOTEA()
// Spawn the keep alive thread. // Spawn the keep alive thread.
theseLogs->logN(1,"Send Test SE at start of OTE Test Hour %d.",hours); theseLogs->logN(1,"Send Test SE at start of OTE Test Hour %d.",hours);
sess->writeXML(TEST_SE); sess->writeXML(TEST_SE);
sess->read(); // sess->read();
sleep(3630); sleep(3630);
} }