char extraId[USERMAXLN];
char userProperty[BUFFMAXLN];
time_t timeIn, timeOut;
+int ipStatus; /* flag for IPV4ONLY,IPV6ONLY or IPV46DUAL */
int connectionMode; /* client connect mode */
+/* variable to measuring processing time (in msec) */
+struct timeval timeBeginCgi, timeBeginWait, timeConnect, timeDisconnect;
+
char sessionId[BUFFMAXLN]; /* session ID */
void PutCloseMsg(time_t timeOut, time_t timeIn);
void SetProcessTitle(char *useridshort, char *clientAddr4, char * ruleNumber4, char *clientAddr6, char * ruleNumber6, int ipStatus);
-void logConnectMode(char *userid);
+void logConnectMode();
void closeExit(int signo);
/***************************************************/
int pid;
int parentpid;
int duration; /* requested usage duration */
+ int durationEntered; /* the duration value is entered or not */
int authResult;
- int ipStatus; /* flag for IPv4 or IPv6 */
- char watchMode[WORDMAXLN]; /* client watch mode Http or Java or Timeout */
+
+ /* get time at the cgi starting (in msec) */
+ gettimeofday(&timeBeginCgi, NULL) ;
/* prepare config file */
if(OpenConfFile()==-1) return 0;
}
/* get POST data */
- if(GetPostData(userid, password, clientAddr4, &duration, watchMode)==FALSE){
+ if(GetPostData(userid, password, clientAddr4, &duration, &durationEntered)==FALSE){
PutClientRetry(language);
return 0;
}
if(pid!=0){
/** parent process **/
/* send accept page with java */
- PutClientAccept(userid, sessionId, port, pid, clientAddr4, clientAddr6, ipStatus, duration, watchMode);
+ PutClientAccept(userid, sessionId, port, pid, clientAddr4, clientAddr6, ipStatus, duration, durationEntered);
/* detach from Web server */
return 0;
Pipe(dummyfd); /* connect dummy pipe for stdin and out */
+ /* get time at the client wait start (in msec) */
+ gettimeofday(&timeBeginWait, NULL) ;
+
/* wait connection from the client */
/* if no connection, close gate when duration is passed */
/* or ipaddr for the macAddr4 is changed */
connectionMode=WaitClientConnect(userid, userProperty, sessionId, clientAddr4, clientAddr6, duration, macAddr4, macAddr6, ipStatus, pClientAddr, language, port, parentpid);
+ /* get time at the client connection (in msec) */
+ gettimeofday(&timeConnect, NULL) ;
+
if(connectionMode==JAVACONNECT){
/* wait until the java applet quit */
else if(connectionMode==HTTPCONNECT){
/* wait until the http keep alive is closed */
- WaitHttpClose(pClientAddr, userid, userProperty, macAddr4, macAddr6, ipStatus);
+ WaitHttpClose(pClientAddr, userid, userProperty, macAddr4, macAddr6, ipStatus, sessionId, port);
}
/* close firewall and exit */
void closeExit(int signo)
{
/* save the connect mode */
- logConnectMode(userid);
+ logConnectMode();
/* signal is disabled */
Signal(SIGTERM, SIG_DFL);
}
-/************************************/
-/* save connectMode to syslog */
-/************************************/
-void logConnectMode(char *userid)
+/*****************************************/
+/* save connectMode and others to syslog */
+/*****************************************/
+void logConnectMode()
{
char *mode[4]={"NONE","JAVA","HTTP","TIME"};
+ long time1sec,time2sec,time3sec;
+ long time1usec,time2usec,time3usec;
+
+ /* set value on failure */
+ if(connectionMode<0 || connectionMode>3) connectionMode=NOCONNECT;
+ if(connectionMode==NOCONNECT){
+ gettimeofday(&timeBeginWait, NULL) ;
+ gettimeofday(&timeConnect, NULL) ;
+ }
+
+ /* get time at the end of connection (in msec) */
+ gettimeofday(&timeDisconnect, NULL) ;
+
+ /* calc time difference (seconds(sec) and micro-seconds(usec)) */
+ time1sec=(timeBeginWait.tv_sec - timeBeginCgi.tv_sec);
+ time1usec=(timeBeginWait.tv_usec - timeBeginCgi.tv_usec);
+ /* if microsec diff is minus, bolow from sec diff */
+ if(time1usec<0){
+ time1usec += 1000000; time1sec--;
+ }
+ time2sec=(timeConnect.tv_sec - timeBeginWait.tv_sec);
+ time2usec=(timeConnect.tv_usec - timeBeginWait.tv_usec);
+ if(time2usec<0){
+ time2usec += 1000000; time2sec--;
+ }
+ time3sec=(timeDisconnect.tv_sec - timeConnect.tv_sec);
+ time3usec=(timeDisconnect.tv_usec - timeConnect.tv_usec);
+ if(time3usec<0){
+ time3usec += 1000000; time3sec--;
+ }
- if(connectionMode<0 || connectionMode>3) connectionMode=0;
- if(debug>0) err_msg("INFO: user %s is watched by [%s]",userid, mode[connectionMode]);
+ if(debug>0) err_msg("INFO: user=%s watchmode=%s procsec=%ld.%06ld,%ld.%06ld,%ld.%06ld ipversion=%d useragent=%s",
+ userid, mode[connectionMode],
+ time1sec,time1usec,
+ time2sec,time2usec,
+ time3sec,time3usec,
+ ipStatus, getenv("HTTP_USER_AGENT"));
}