#include "opengatemmng.h"
-/* convert one-char-hex "a" to one-number 0Xa */
+/* convert one-char-hex "a" to one-number 0Xa */
#define hex2num(x) ((x)>='A' ? ((x) & 0XDF) - 'A' +10 : ((x) - '0'))
void split(char content[], char *name[], char *value[], char *next[]);
char macAddress[ADDRMAXLN]="";
/********************************************/
-/* get Post data from the client */
+/* get Post data sent from the client */
/********************************************/
-int getPostData(char *content, int contentMaxLength)
-{
+int getPostData(char *content, int contentMaxLength){
int contentLen;
/* get content sent from web input */
return TRUE;
}
-/********************************************/
+/****************************************************/
/* get language form query string (in url lang=ja) */
-/********************************************/
+/****************************************************/
int getLangFromQueryString(char* language){
int found=FALSE;
return found;
}
-/********************************************/
-/* get redirected url form query string */
-/********************************************/
+/*********************************************************************/
+/* get redirected url form query string (in url redirectedurl=xxxxx) */
+/*********************************************************************/
int getRedirectedUrlFromQueryString(char* redirectedUrl){
int found=FALSE;
return found;
}
-/********************************************/
-/* get mac address form query string (in url lang=ja) */
-/********************************************/
+/*************************************************************/
+/* get mac address form query string (in url macaddr=xxxxx) */
+/*************************************************************/
int getMacAddrFromQueryString(char* macAddress){
int found=FALSE;
}
-/********************************************/
-/* get userid from environment variable */
-/* long userid: "userid@extraid" is set */
-/********************************************/
+/**************************************************/
+/* get userid from environment variable */
+/* long userid: "userid@extraid" is set in env */
+/**************************************************/
int getUserIdFromEnv(char *userid){
int ret=FALSE;
char* pEnv=NULL;
/* if shibboleth or httpbasic, get uid from environment var */
- /* shibboleth */
+ /*** case of shibboleth */
if(strcmp(GetConfValue("AuthServer/Protocol"), "shibboleth")==0){
- /* get data from env-variables for uid and org attribute */
+ /* get data from env-variables for uid and org attribute, if env-var exists */
pEnv=getenvEx(GetConfValue("AuthServer/UidAttribute"),TRUE,TRUE);
if(!isNull(pEnv)){
strlcpy(userid, pEnv, USERMAXLN);
- /* if orp string can be get from env var, concatenate it as uid@org */
+ /* if orp string can be get from env-var, concatenate it as uid@org */
pEnv=getenvEx(GetConfValue("AuthServer/OrgAttribute"),TRUE,TRUE);
if(!isNull(pEnv)){
strlcat(userid, GetConfValue("UserIdSeparator"), USERMAXLN);
ret=TRUE;
}
- /* get from env-variable for EPPN(edu person principal name) attribute */
+ /* else, get name from env-variable for EPPN(edu person principal name) attribute */
else{
pEnv=getenvEx(GetConfValue("AuthServer/EppnAttribute"),TRUE,FALSE);
if(!isNull(pEnv)){
}
}
+ /* if not get, error exit */
if(ret==FALSE){
err_msg("ERR at %s#%d: Cannot get user info from shibboleth",__FILE__,__LINE__);
PutMessageToClient("Cannot get user info from shibboleth<br>Check shibboleth setting in .htaccess, conf and others");
}
}
- /* httpbasic */
+ /*** case of httpbasic */
else if(strcmp(GetConfValue("AuthServer/Protocol"), "httpbasic")==0){
if(!isNull(getenv("REMOTE_USER"))){
strlcpy(userid,getenv("REMOTE_USER"),USERMAXLN);
}else{
err_msg("ERR at %s#%d: Cannot get user info from httpbasic",__FILE__,__LINE__);
ret=FALSE;
- PutMessageToClient("Cannot get user info from http basic<br>Check http basic setting in .htaccess and other");
+ PutMessageToClient("Cannot get user info from http basic<br>Check http-basic setting in .htaccess and other");
exit(0);
}
}
return ret;
}
-/*******************************
-get userid and password from post string
-*******************************/
+/********************************************/
+/* get userid and password from post string */
+/********************************************/
int getUserIdFromPostData(char* requestStr, char* userid, char* password){
char *name[1];
/* copy it to work area */
strlcpy(content, requestStr, BUFFMAXLN);
- /* split request item and execute the request */
+ /* split request item and pick up userid and password */
ptr=content;
while(ptr!=NULL){
return ret;
}
-/********************************************/
-/* analyze request for checking */
-/********************************************/
-int analyzeCheckRequest(char *content, int* status, char* macAddress)
-{
+/*********************************************/
+/* analyze request from mac check page */
+/* content: (input) request string */
+/* status: (output) OPEN(1)/CLOSE(0)/NONE(-1)*/
+/* macAddress: (output) mac addr */
+/*********************************************/
+int analyzeCheckRequest(char *content, int* status, char* macAddress){
char *name[1];
char *value[1];
char *next[1];
*status=NONE;
*macAddress='\0';
- /* split request item and execute the request */
+ /* split request item and pick up status(open/close) and macAddress */
ptr=content;
while(!isNull(ptr)){
}
/********************************************/
-/* analyze request and execute request for registering */
+/* analyze request from mac register page */
/********************************************/
-int analyzeRegisterRequest(char *content, char* macAddress, char* deviceName, char* mailAddress)
-{
+int analyzeRegisterRequest(char *content, char* macAddress, char* deviceName, char* mailAddress){
char *name[1];
char *value[1];
char *next[1];
char *ptr;
+ /* if null request, return false */
+ if(isNull(content)) return FALSE;
+
/* set default */
*macAddress='\0';
*deviceName='\0';
*mailAddress='\0';
- /* split request item and execute the request */
+ /*** split item in request and pick up macAddress,deviceName,mailAddress */
+ /* scan the content string of request */
ptr=content;
while(!isNull(ptr)){
ptr=next[0];
}
- /* if illegal device name, return */
+ /* if null or illegal device name, return false */
if(*deviceName=='\0'){
SetMessage(EmptyDeviceName);
return FALSE;
return FALSE;
}
- /* if illegal mail address, return */
+ /* if illegal mail address, return false */
+ /* (null mail address is permitted) */
if(*mailAddress!='\0'){
if(!IsSafeString(mailAddress, BUFFMAXLN)){
SetMessage(IllegalCharInMailAddr);
}
}
- /* if illegal mac address, return */
+ /* if illegal mac address, return false */
if(!ConvertMacAddr(macAddress)) return FALSE;
- /* if already registered in db, return */
+ /* if already registered in db, return false */
if(IsMacAddrFoundInMngDb(macAddress)){
SetMessage(ExistentMacAddr);
return FALSE;
return TRUE;
}
-/******************************
- convert mac address to regular format
- [01:23:45:67:89:0a]
-******************************/
+/*****************************************/
+/* convert mac address to regular format */
+/* [01:23:45:67:89:0a] */
+/* (colon separate, lower case letters) */
+/*****************************************/
int convertMacAddr(char* macAddr){
- int m[6]; /* mac address sequence */
+ int m[6]; /* mac address sequence 6-bytes */
int i;
/* normal form is hex:hex:hex:hex:hex:hex */
return TRUE;
}
-/******************************
-check safe characters string
-******************************/
+/********************************/
+/* check safe characters string */
+/********************************/
int isSafeString(char* str, int length){
char allowableChar[]=" !#$&*+,-./:=?[]^_{|}@";
int i;
for(i=0; i<length; i++){
ch=str[i];
- /* if reached to the end of string, return true */
+ /* if reached to the end of string, break loop */
if(ch=='\0') break;
- /* if alpha or numeric is found, goto next char */
+ /* if char is alpha or numeric, goto next char */
if(isalnum(ch)) continue;
- /* if control or non ascii is found, return false */
+ /* if char is control or non-ascii, return false */
if( (unsigned)ch < 0x20|| 0x7f < (unsigned)ch) return FALSE;
- /* if one of above list is found, goto next char */
+ /* if char is not allowable, return false */
if(strchr(allowableChar, ch)==NULL) return FALSE;
}
+ /* all char is safe */
return TRUE;
}
/*********************************************/
-/* put auth request page to client */
+/* put auth request page to client */
/*********************************************/
-int putAuthRequestPageToClient(char *language, char* cgiName, char* docName, char* redirectedUrl)
-{
+int putAuthRequestPageToClient(char *language, char* cgiName, char* docName, char* redirectedUrl){
char authdoc[BUFFMAXLN];
FILE *fp;
char buff[BUFFMAXLN];
- /* make read in path to the retry document */
+ /* make directory path to the auth page document template file */
snprintf(authdoc, BUFFMAXLN, "%s%s/%s/%s",GetConfValue("DocumentRoot"),
GetConfValue("OpengateDir"),language,docName);
/* replace keyword and send out the file */
printf("Content-type: text/html\r\n\r\n");
+ /* open the template file */
if((fp=fopen(authdoc, "r"))==NULL){
err_msg("ERR at %s#%d: cannot find file %s",__FILE__,__LINE__, authdoc);
return FALSE;
}
+ /* read line from template file, replace variables, and write to client */
while(fgets(buff,BUFFMAXLN,fp)!=NULL){
HtmlReplace(buff, "%%CGINAME%%", cgiName);
HtmlReplace(buff, "%%REDIRECTEDURL%%", redirectedUrl);
return TRUE;
}
-/*********************************************/
-/* deny message to the client */
-/*********************************************/
+/*****************************************/
+/* deny message page to the client */
+/*****************************************/
int putDenyToClient(char *language){
char denydoc[BUFFMAXLN];
FILE *fp;
char buff[BUFFMAXLN];
- /* make read in path to the retry document */
+ /* make read in path to the deny document */
snprintf(denydoc, BUFFMAXLN, "%s%s/%s/%s",GetConfValue("DocumentRoot"),
GetConfValue("OpengateDir"),language,GetConfValue("DenyDoc"));
/* replace keyword and send out the file */
printf("Content-type: text/html\r\n\r\n");
+ /* open the template file */
if((fp=fopen(denydoc, "r"))==NULL){
err_msg("ERR at %s#%d: cannot find file %s",__FILE__,__LINE__, denydoc);
return FALSE;
}
+ /* read line from template file, replace variables, and write to client */
while(fgets(buff,BUFFMAXLN,fp)!=NULL){
if(strstr(buff, "%%ERRORLIST%%")!=NULL){
InsertMessageToPage(language);
return TRUE;
}
-/*********************************************/
-/* put response to client for check request */
-/*********************************************/
-int putCheckPageToClient(char *language, char* userId, char* extraId)
-{
+/*****************************************/
+/* put mac address check page to client */
+/* the page includes detected mac list */
+/*****************************************/
+int putCheckPageToClient(char *language, char* userId, char* extraId){
char responsedoc[BUFFMAXLN];
FILE *fp;
char buff[BUFFMAXLN];
/* end of http header */
printf("\r\n");
- /* replace keyword and send out the file */
+ /* open the template file */
if((fp=fopen(responsedoc, "r"))==NULL){
err_msg("ERR at %s#%d: cannot find file %s",__FILE__,__LINE__, responsedoc);
return FALSE;
}
-
+ /* read line from template file, replace variables, and write to client */
while(fgets(buff,BUFFMAXLN,fp)!=NULL){
HtmlReplace(buff, "%%CHECKCGI%%", chkCgi);
HtmlReplace(buff, "%%REGISTERCGI%%", regCgi);
else if(strstr(buff, "%%ERRORLIST%%")!=NULL){
InsertMessageToPage(language);
}
-
else{
printf("%s",buff);
}
fclose(fp);
return TRUE;
}
-/*********************************************/
-/* put response to client for register request */
+/***********************************************************/
+/* put mac register page to client */
/* ownReg:1=the page is controlled by owner, 0=under admin */
-/*********************************************/
-int putRegisterPageToClient(char *language, char* macAddress, char* deviceName, char* mailAddress, char* userId, char* extraId, int ownReg, char* redirectedUrl)
-{
+/***********************************************************/
+int putRegisterPageToClient(char *language, char* macAddress, char* deviceName, char* mailAddress, char* userId, char* extraId, int ownReg, char* redirectedUrl){
char responsedoc[BUFFMAXLN];
FILE *fp;
char buff[BUFFMAXLN];
char cookie[SIDMAXLN];
char* regCgi="";
char* regDoc="";
+ char* maxDevicesStr;
+ /* get Maximum count of devices for an user from conf file */
+ maxDevicesStr=GetConfValue("MaxDevices");
/* setup cgi and doc */
if(ownReg){
return FALSE;
}
- /* make read in path to the document */
+ /* make path to the document template file */
snprintf(responsedoc, BUFFMAXLN, "%s%s/%s/%s",GetConfValue("DocumentRoot"),
GetConfValue("OpengateDir"),language,regDoc);
/* end of http header */
printf("\r\n");
+ /* open the template file */
if((fp=fopen(responsedoc, "r"))==NULL){
err_msg("ERR at %s#%d: cannot find file %s",__FILE__,__LINE__, responsedoc);
return FALSE;
}
+ /* read line from template file, replace variables, and write to client */
while(fgets(buff,BUFFMAXLN,fp)!=NULL){
HtmlReplace(buff, "%%REGISTERCGI%%", regCgi);
HtmlReplace(buff, "%%MACADDR%%", macAddress);
HtmlReplace(buff, "%%MAILADDR%%", mailAddress);
HtmlReplace(buff, "%%USERID%%", userId);
HtmlReplace(buff, "%%REDIRECTEDURL%%", redirectedUrl);
+ HtmlReplace(buff, "%%MAXDEVICES%%", maxDevicesStr);
if(strstr(buff, "%%MACREGLIST%%")!=NULL){
PutMacRegListToClient(userId, extraId);
return TRUE;
}
-/*********************************************/
-/* put mac list in mac check table to the client */
-/*********************************************/
+/********************************************************/
+/* put mac-check table in mac-check page */
+/* mac-check table is prepared in work db with arp/ndp */
+/* it is used for candidates of mac to register */
+/* (at registration by admin) */
+/********************************************************/
void putMacCheckListToClient(void){
char macAddress[ADDRMAXLN];
/* print out table row */
/* the row is colored, if it is a candidate for registering */
- /* the terminals inUse/foundInDb may be not the candidate */
+ /* the terminals inUse/foundInDb is probably not the candidate */
if(inUse || foundOnDb){
printf("<tr align=middle>\n");
}else{
printf("<tr style='background-color: rgb(255,255,204);' align=middle>\n");
}
- /* check radio button in first row */
+ /* show radio button, checked on first row */
if(firstRow){
printf("<td><input type='radio' name='macaddr' value='%s' checked></td>\n", macAddress);
firstRow=FALSE;
}
}
-/*********************************************/
-/* put mac regsitered list the client */
-/*********************************************/
+/************************************************/
+/* put list of mac address regisitered in db */
+/************************************************/
void putMacRegListToClient(char* userId, char* extraId){
char deviceName[WORDMAXLN]="";
while(GetNextMacAddrFromMngDb(userId,extraId,macAddress,deviceName,
entryDate,limitDate,status,mailAddress)){
-
printf("<tr align=middle>\n");
printf("<td>%s</td>\n", macAddress);
printf("<td>%s</td>\n",deviceName);
printf("</BODY></HTML> \r\n\r\n");
}
-/************************************************/
-/* send page for returning to the previous page */
-/************************************************/
+/*************************************************/
+/* send page that auto-returns to redirectedUrl */
+/* after delay (ReturnWaitTime is in conf) */
+/*************************************************/
void returnToRedirectedPage(char* redirectedUrl, char* language){
char returndoc[BUFFMAXLN];
/* send header */
printf("Content-type: text/html\r\n\r\n");
-
+
+ /* open the template file */
if((fp=fopen(returndoc, "r"))==NULL){
err_msg("ERR at %s#%d: cannot find file %s",__FILE__,__LINE__, returndoc);
printf("Error! \r\n\r\n");
return;
}
+ /* get return wait time from conf */
+ /* (it is inserted as Refresh time in the page) */
if(!isNull(GetConfValue("ReturnWaitTime"))){
waitTime=GetConfValue("ReturnWaitTime");
}
+
+ /* read line from template file, replace variables, and write to client */
while(fgets(buff,BUFFMAXLN,fp)!=NULL){
HtmlReplace(buff, "%%WAITTIME%%", waitTime);
HtmlReplace(buff, "%%REDIRECTEDURL%%", redirectedUrl);
fclose(fp);
}
-/************************************/
-/* split value for indicated name */
-/* in content "name=value&..." */
-/************************************/
-void split(char content[], char *name[], char *value[], char *next[])
-{
+/*************************************************************/
+/* split name and value in content such as "name=value&..." */
+/* input:content, output:name,value,next */
+/*************************************************************/
+void split(char content[], char *name[], char *value[], char *next[]){
char *pstr;
/* set default */
return;
}
-/**********************************/
-/* decode text coding in web post */
-/**********************************/
+/*****************************************/
+/* decode text coding in web post */
+/* eg. "+%21" => " !"(space,exclamation) */
+/* string: input and output */
+/*****************************************/
void decode(char *string)
{
char *pcheck, *pinsert;
}
-/*****************************************************/
-/* replace beforeStr to afterStr in string in buff */
-/*****************************************************/
-int htmlReplace(char* buff,char *beforeStr,char *afterStr)
-{
+/********************************************/
+/* replace beforeStr to afterStr in buff */
+/* buff: input and output */
+/* beforeStr,afterStr: input */
+/* if afterStr is too long, tail is cut-off */
+/********************************************/
+int htmlReplace(char* buff,char *beforeStr,char *afterStr){
char *pBuff , *pNext;
char tempBuff[BUFFMAXLN];
}
/*****************************************************/
-/* split a str at delimStr and return the point */
+/* split a str at delimStr and return next pointer */
+/* str: input and output */
+/* delimStr: input */
+/* eg. IN: str="abcdefghijk" delimStr="def" */
+/* OUT: str="abc###ghijk" '#' means null(\0) */
+/* |________ pointer returned */
/*****************************************************/
-char* strSplit(char* str,const char* delimStr)
-{
+char* strSplit(char* str, const char* delimStr){
char* delimPoint = strstr(str,delimStr);
const size_t delimLen = strlen(delimStr);
/**********************/
/* get HTTP-Cookie */
/**********************/
- /* cookie string examples
- "OpengateMmng=de..ac1&Userid=user1"
- "OpengateMmng=de..ac1&Userid=user1; xxx=..; yyy=.."
- "xxx=..; yyy=..; OpengateMmng=de..ac1&Userid=user1"
- */
+/********************************************************/
+/*cookie is picked out from the cookie string such as */
+/* "OpengateMmng=de..ac1&Userid=user1" */
+/* "OpengateMmng=de..ac1&Userid=user1; xxx=..; yyy=.." */
+/* "xxx=..; yyy=..; OpengateMmng=de..ac1&Userid=user1" */
+/* cookieName:(input) "OpengateMmng" defined in conf */
+/* cookie:(output) value of above cookie name */
+/********************************************************/
int getHttpCookie(char *cookie, char* cookieName){
char content[BUFFMAXLN];
char *name[1];
else return TRUE;
}
-/*************************************
-compare received cookie to previously saved one
-*************************************/
+/*****************************************************/
+/* compare received cookie with previously saved one */
+/*****************************************************/
int isCorrectCookie(char* cookie, int userType){
char userId[USERMAXLN];
char extraId[USERMAXLN];
return FALSE;
}
-/********************************************/
-/* analyze update request and execute request */
-/********************************************/
-int analyzeUpdateRequestAndExecute(char *requestStr, char* userId, char* extraId)
-{
+/************************************************/
+/* analyze update request and execute request */
+/************************************************/
+int analyzeUpdateRequestAndExecute(char *requestStr, char* userId, char* extraId){
char *name[1];
char *value[1];
char *next[1];
char *ptr;
char macAddr[ADDRMAXLN];
- int modified=FALSE; /* database modification is executed */
+ int modified=FALSE; /* status of database modification */
int ret;
char content[BUFFMAXLN];
char deviceName[WORDMAXLN]="";
char mailAddress[BUFFMAXLN]="";
- /* if null string, return */
+ /* if null string, return false */
if(isNull(requestStr)) return FALSE;
/* copy request string to work area */
strlcpy(content, requestStr, BUFFMAXLN);
- /* split request item and execute the request */
+ /*** split item and execute the request(from following input forms) */
/* <input type=radio name=11:22:33:44:55:66 value=extend> */
/* <input type=radio name=11:22:33:44:55:66 value=pause> */
/* <input type=radio name=11:22:33:44:55:66 value=delete> */
/* <input type=hidden name=11:22:33:44:55:66 value=mail:wata@foo.bar> */
/* <input type=hidden name=11:22:33:44:55:66 value=name:iPhone01> */
+ /* point to the head of string and scan the string to the tail */
ptr=content;
while(ptr!=NULL){
/* if item=delete, execute delete */
if(strcmp(value[0], "delete")==0){
- strlcpy(macAddr, name[0], ADDRMAXLN);
- decode(macAddr);
- if(ConvertMacAddr(macAddr)){
- ret=DelMacAddrFromMngDb(macAddr);
+ strlcpy(macAddr, name[0], ADDRMAXLN); /* copy mac to work area */
+ decode(macAddr); /* decode html encoding */
+ if(ConvertMacAddr(macAddr)){ /* convert to colon & lower-char str */
+ ret=DelMacAddrFromMngDb(macAddr); /* remove mac from db */
if(ret){
modified=TRUE;
- PutMacModifyLogToMngDb(userId, extraId, macAddr, 'D');
- PutMacAddressToServers(macAddr);
+ PutMacModifyLogToMngDb(userId, extraId, macAddr, 'D'); /* save change log */
+ PutMacAddressToServers(macAddr); /* send mac to opengatemd daemons */
}
}
}
return modified;
}
-/*********************************************/
-/* put response to client */
+/**********************************************************/
+/* put update page to client */
/* ownUpdate:1=page is controlled by owner, 0=under admin */
-/*********************************************/
-int putUpdatePageToClient(char *language, char* userId, char* extraId, int ownUpdate, char* redirectedUrl)
-{
+/**********************************************************/
+int putUpdatePageToClient(char *language, char* userId, char* extraId, int ownUpdate, char* redirectedUrl){
char responsedoc[BUFFMAXLN];
FILE *fp;
char buff[BUFFMAXLN];
/* end of http header */
printf("\r\n");
+ /* open the template file */
if((fp=fopen(responsedoc, "r"))==NULL){
err_msg("ERR at %s#%d: cannot find file %s",__FILE__,__LINE__, responsedoc);
return FALSE;
}
+ /* read line from template file, replace variables, and write to client */
while(fgets(buff,BUFFMAXLN,fp)!=NULL){
-
HtmlReplace(buff, "%%CGINAME%%", updateCgi);
HtmlReplace(buff, "%%USERID%%", userId);
HtmlReplace(buff, "%%REDIRECTEDURL%%", redirectedUrl);
return TRUE;
}
+
/*********************************************/
-/* put mac list the client */
+/* put mac list for the user to the client */
/*********************************************/
void putMacListToClient(char* userId, char* extraId){
char macAddr[ADDRMAXLN];
char mailAddress[BUFFMAXLN];
- /* make rows for deletion and extending */
- /* get registered mac list form db and insert */
+ /*** make html-table for deletion and extending the registration */
+ /* following code inserts table row of a mac address for the user */
+ /* (table skeleton is prepared in in template file) */
+ /* --example of the row-- */
+ /* <tr align=middle> */
+ /* <td><input type=radio name=11:22:33:44:55:66 value=extend></td> */
+ /* <td><input type=radio name=11:22:33:44:55:66 value=pause></td> */
+ /* <td><input type=radio name=11:22:33:44:55:66 value=delete></td> */
+ /* <td>11:22:33:44:55:66</td> */
+ /* <td>onclick="editstring('11:22:33:44:55:66','name',this)">iPhone1</td> */
+ /* <td>onclick="editstring('11:22:33:44:55:66','mail',this)">wata@foo.bar</td> */
+ /* <td>2000/01/03 01:23:45</td> */
+ /* <td>2000/02/01 00:00:00</td> */
+ /* <td>A</td> */
+ /* </tr> */
+ /* ---- */
+ /* editstring is a javascript function to edit string in html-item */
+
+ /* get registered mac form db */
while(GetNextMacAddrFromMngDb(userId,extraId,macAddr,deviceName,
entryDate,limitDate,status,mailAddress)){
+
+ /* put out a html table row to the client */
printf("<tr align=middle>\n");
if((status[0]=='A')||(status[0]=='P')){
printf("<td><input type=radio name=%s value=extend checked></td>\n",
char* p;
int count=0;
- /* get usage log from db and insert as JSON format */
+ /*** get usage log and insert it to html doc as JSON format */
+ /* get one log form management db */
while(GetNextUsageLogFromMngDb(userId,extraId,macAddr,deviceName,
openTime,closeTime,gatewayName)){
- /* split hostname only */
+ /* split hostname only (opengate01.example.com -> opengate01) */
if((p=strchr(gatewayName,'.'))!=NULL) *p='\0';
- /* put out table row */
+ /* put out the log as a JSON item */
+ /* table skeleton is prepared in template file */
printf("\t %d:{\n", count);
printf("\t\t macAddress: '%s',\n", macAddr);
printf("\t\t device: '%s',\n",deviceName);
printf("\t\t gateway: '%s'\n",gatewayName);
printf("\t },\n");
- /* increment log item counter */
+ /* increment log counter */
count++;
}
- /* put out informations for the list */
+ /* put out the JSON item for summary info of the list */
GetTimeRangeToShowLog(beginTime, endTime, &dateCount);
printf("\t info:{\n");
printf("\t\t beginTime: '%s',\n", beginTime);
printf("\t }\n");
}
-/**********************************************/
-/* check allowable http-agent defined in conf */
-/**********************************************/
+/********************************************************/
+/* the client is an allowable http-user-agent or not */
+/* the allowable http-user-agent can be defined in conf */
+/* (if no definition, all agents are allowed) */
+/* the agent is described with Regular Expression */
+/********************************************************/
int isAccessedFromAllowableAgent(void){
char* pAgent=NULL;