1 /**************************************************
2 OpengateM - MAC address authentication system
4 module to control management database
9 Copyright (C) 2011 Opengate Project Team
10 Written by Yoshiaki Watanabe
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2
15 of the License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 Email: watanaby@is.saga-u.ac.jp
27 **************************************************/
28 #include "opengatemmng.h"
33 /******************************************
34 initialize management db
35 ******************************************/
39 char *server = GetConfValue("MySqlDb/Server");
40 char *user = GetConfValue("MySqlDb/User");
41 char *password = GetConfValue("MySqlDb/Password");
42 char *database = GetConfValue("MySqlDb/Database");
45 /* initialize mysql */
46 mysql_library_init(-1,NULL,NULL);
47 if(mysql_init(&mysql)==NULL){
48 err_msg("ERR at %s#%d: mysql init: %s",__FILE__,__LINE__,
53 /* Connect to database */
54 if (!mysql_real_connect(&mysql, server,
55 user, password, database, 0, NULL, 0)) {
56 err_msg("ERR at %s#%d: mysql connect: %s",__FILE__,__LINE__,
61 /* set auto-reconnect true */
63 mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
68 /******************************************
70 ******************************************/
71 void closeMngDb(void){
77 /******************************************
78 get nic vendor from management db
79 ******************************************/
80 int getNicVendorFromMngDb(char* macAddress, char* vendor, int bufferLength){
85 char queryStr[BUFFMAXLN];
86 char macHeader[ADDRMAXLN];
88 /* set default values */
92 /* prepare query string */
93 strlcpy(macHeader, macAddress, ADDRMAXLN);
95 snprintf(queryStr, BUFFMAXLN,
96 "select org from nicvendors where oui='%s'",
100 if (mysql_query(&mysql, queryStr)){
101 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
102 mysql_error(&mysql));
106 res = mysql_use_result(&mysql);
108 /* output table name */
109 row = mysql_fetch_row(res);
111 /* if not found, return false */
112 if(row==NULL) found=FALSE;
116 strlcpy(vendor, row[0], bufferLength);
120 mysql_free_result(res);
124 /******************************************
125 The macAddr is already registered
126 ******************************************/
127 int isMacAddrFoundInMngDb(char* macAddr){
131 char queryStr[BUFFMAXLN];
134 /* prepare query string */
135 snprintf(queryStr, BUFFMAXLN,
136 "select * from macaddrs "
137 " where macAddress='%s' and status!='D'",
141 if (mysql_query(&mysql, queryStr)){
142 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
143 mysql_error(&mysql));
148 res = mysql_store_result(&mysql);
150 /* output table name */
151 row = mysql_fetch_row(res);
153 /* if found, return true */
154 if(row!=NULL) ret=TRUE;
156 /* if not found, return false */
159 mysql_free_result(res);
163 /******************************************
164 The count of registered mac address for the user
165 ******************************************/
166 int countMacAddrsForUserInMngDb(char* userId, char* extraId){
170 char queryStr[BUFFMAXLN];
171 char countStr[WORDMAXLN];
174 /* prepare query string */
175 snprintf(queryStr, BUFFMAXLN,
176 "select count(*) from macaddrs "
177 " where userId='%s' and extraId='%s' and status!='D'",
181 if (mysql_query(&mysql, queryStr)){
182 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
183 mysql_error(&mysql));
188 res = mysql_store_result(&mysql);
190 /* output table name */
191 row = mysql_fetch_row(res);
193 /* if found, return values */
195 strlcpy(countStr, row[0], WORDMAXLN);
196 count=atoi(countStr);
199 /* free memory area */
200 mysql_free_result(res);
205 /******************************************
206 register mac address to the management db
207 ******************************************/
208 int registMacAddrToMngDb(char* macAddr, char* deviceName, char* userId, char* extraId, char* mailAddr){
210 char queryStr[BUFFMAXLN];
213 /* if alreay registered (and not deleted yet), return false */
214 if(IsMacAddrFoundInMngDb(macAddr)){
215 SetMessage(ExistentMacAddr);
219 /* if the user registered device more than limit, return false */
220 count=CountMacAddrsForUserInMngDb(userId,extraId);
221 if(count >= atoi(GetConfValue("MaxDevices"))){
222 SetMessage(DeviceCountOver);
226 /* prepare query string */
227 snprintf(queryStr, BUFFMAXLN,
228 "insert into macaddrs "
229 "(macAddress, status, device, userId, extraId, "
230 " entryDate, renewDate, limitDate, mailAddress) "
231 "values ('%s','A','%s', '%s', '%s', "
232 " now(), now(), %s, '%s')",
233 macAddr, deviceName, userId, extraId,
234 GetConfValue("LimitDate"), mailAddr);
237 if (mysql_query(&mysql, queryStr)){
238 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
239 mysql_error(&mysql));
246 /*******************************************
247 get next mac address from management db
248 if end of list, return false
249 *******************************************/
250 int getNextMacAddrFromMngDb(char* userId, char* extraId, char* macAddress, char* deviceName, char* entryDate, char* limitDate, char* status, char* mailAddress){
252 static MYSQL_RES *res=NULL;
254 char queryStr[BUFFMAXLN];
256 /* set default values */
257 macAddress[0]=deviceName[0]=entryDate[0]=limitDate[0]='\0';
259 /* if do not get result yet */
262 /* prepare query string */
263 snprintf(queryStr, BUFFMAXLN,
264 "select macAddress, device, entryDate, limitDate, status, mailAddress "
265 "from macaddrs where userId='%s' and extraId='%s' and status!='D'",
269 if (mysql_query(&mysql, queryStr)){
270 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
271 mysql_error(&mysql));
276 res = mysql_store_result(&mysql);
279 /* output table name */
280 row = mysql_fetch_row(res);
282 /* if found, return values */
284 strlcpy(macAddress, row[0],ADDRMAXLN);
285 strlcpy(deviceName,row[1],WORDMAXLN);
286 strlcpy(entryDate,row[2],WORDMAXLN);
287 strlcpy(limitDate,row[3],WORDMAXLN);
288 strlcpy(status,row[4],WORDMAXLN);
289 strlcpy(mailAddress,row[5],BUFFMAXLN);
292 /* if not found, free memory area */
294 mysql_free_result(res);
300 /******************************************
301 write mac modification log to the management db
302 ******************************************/
303 int putMacModifyLogToMngDb(char* userId, char* extraId, char* macAddr, char modifyType){
305 char queryStr[BUFFMAXLN];
307 /* prepare query string */
308 snprintf(queryStr, BUFFMAXLN,
309 "insert into macmodify "
310 "(userId, extraId, macAddress, modifyType, modifyDate) "
311 "values ('%s', '%s', '%s', '%c', now())",
312 userId, extraId, macAddr, modifyType);
315 if (mysql_query(&mysql, queryStr)){
316 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
317 mysql_error(&mysql));
324 /******************************************
325 The count of mac address modification in last 24 hours
326 ******************************************/
327 int countMacModifyPerDayInMngDb(char* userId, char* extraId, char* macAddress){
331 char queryStr[BUFFMAXLN];
332 char countStr[WORDMAXLN];
335 /* prepare query string */
336 /* count for one macAddress if not null, elsecount for one userID)*/
337 if(!isNull(macAddress)){
338 snprintf(queryStr, BUFFMAXLN,
339 "select count(*) from macmodify "
340 " where macAddress='%s' and "
341 " modifyDate > adddate(now(), interval -1 day) ",
344 snprintf(queryStr, BUFFMAXLN,
345 "select count(*) from macmodify "
346 " where userId='%s' and extraId='%s' and "
347 " modifyDate > adddate(now(), interval -1 day) ",
352 if (mysql_query(&mysql, queryStr)){
353 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
354 mysql_error(&mysql));
359 res = mysql_store_result(&mysql);
361 /* output table name */
362 row = mysql_fetch_row(res);
364 /* if found, return values */
366 strlcpy(countStr, row[0], WORDMAXLN);
367 count=atoi(countStr);
370 /* free memory area */
371 mysql_free_result(res);
376 /******************************************
377 delete a mac address registered in the management db
378 do not delete, but set the status flag to 'D'
379 ******************************************/
380 int delMacAddrFromMngDb(char* macAddr){
382 char queryStr[BUFFMAXLN];
384 /* if the mac data was used, it is preserved for usage log */
385 if(IsSessionFoundInMngDb(macAddr)){
387 /* prepare query string */
388 /* if session for the mac exists, the row is preserved */
389 /* don't touch device set as status=Inactive */
390 snprintf(queryStr, BUFFMAXLN,
391 "update macaddrs set status='D',limitDate=now() "
392 " where macAddress='%s' and (status='A' or status='P')", macAddr);
395 /* prepare query string */
396 /* if session does not exist, the row is removed */
397 /* don't touch device set as status=Inactive */
398 snprintf(queryStr, BUFFMAXLN,
399 "delete from macaddrs "
400 " where macAddress='%s' and (status='A' or status='P')", macAddr);
404 if (mysql_query(&mysql, queryStr)){
405 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
406 mysql_error(&mysql));
412 /******************************************
413 renew the limit date for a mac address
414 registered in the management db
415 ******************************************/
416 int renewMacAddrInMngDb(char* macAddr){
418 char queryStr[BUFFMAXLN];
420 /* prepare query string */
421 /* don't touch device set as inactive by admin */
422 snprintf(queryStr, BUFFMAXLN,
423 "update macaddrs set status='A', renewDate=now(), limitDate=%s "
424 " where (status='A' or status='P') and macAddress='%s'",
425 GetConfValue("LimitDate"),macAddr);
428 if (mysql_query(&mysql, queryStr)){
429 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
430 mysql_error(&mysql));
436 /******************************************
437 pause the usage of the device for a mac address
438 registered in the management db
439 ******************************************/
440 int pauseMacAddrInMngDb(char* macAddr){
442 char queryStr[BUFFMAXLN];
444 /* prepare query string */
445 /* don't touch device set as inactive by admin */
446 snprintf(queryStr, BUFFMAXLN,
447 "update macaddrs set status='P' "
448 " where status='A' and macAddress='%s' and limitDate>now()",
452 if (mysql_query(&mysql, queryStr)){
453 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
454 mysql_error(&mysql));
460 /******************************************
461 is the mac address used in session log
462 ******************************************/
463 int isSessionFoundInMngDb(char* macAddr){
467 char queryStr[BUFFMAXLN];
470 /* prepare query string */
471 /* get row for addr.entry<session.open<addr.limit */
472 snprintf(queryStr, BUFFMAXLN,
473 "select * from macaddrs, sessionmd "
474 " where macaddrs.macAddress=sessionmd.macAddress and "
475 " macaddrs.macAddress='%s' and "
476 " entryDate<openTime and openTime<limitDate",
480 if (mysql_query(&mysql, queryStr)){
481 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
482 mysql_error(&mysql));
487 res = mysql_store_result(&mysql);
489 /* output table name */
490 row = mysql_fetch_row(res);
492 /* if found, return true */
493 if(row!=NULL) ret=TRUE;
495 /* if not found, return false */
498 mysql_free_result(res);
502 /*******************************************
503 get next next usage log from management db
504 if end of list, return false
505 *******************************************/
506 int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* deviceName, char* openTime, char* closeTime, char* gatewayName){
507 static MYSQL_RES *res=NULL;
509 char queryStr[BUFFMAXLN];
511 /* set default values */
512 macAddr[0]=deviceName[0]=openTime[0]=gatewayName[0]='\0';
514 /* if do not get result yet */
517 /* prepare query string */
518 /* get log where addr.entry < session.open < addr.limit */
519 /* (the same device may be registered by other users in old days) */
520 snprintf(queryStr, BUFFMAXLN,
521 "select macaddrs.macAddress, device, openTime, closeTime, "
523 " from macaddrs, sessionmd "
524 " where macaddrs.macAddress=sessionmd.macAddress "
525 " and entryDate < openTime and openTime < limitDate "
526 " and (%s<closeTime or closeTime=0) "
527 " and userId='%s' and extraId='%s'",
528 GetConfValue("ShowLogAfter"), userId, extraId);
531 if (mysql_query(&mysql, queryStr)){
532 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
533 mysql_error(&mysql));
538 res = mysql_store_result(&mysql);
541 /* output table name */
542 row = mysql_fetch_row(res);
544 /* if found, return values */
546 strlcpy(macAddr, row[0],ADDRMAXLN);
547 strlcpy(deviceName,row[1],WORDMAXLN);
548 strlcpy(openTime,row[2],WORDMAXLN);
549 strlcpy(closeTime,row[3],WORDMAXLN);
550 strlcpy(gatewayName,row[4],WORDMAXLN);
553 /* if not found, free memory area */
555 mysql_free_result(res);
561 /*******************************************
562 get next mail address near limit date
564 *******************************************/
565 int getNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char* device){
567 static MYSQL_RES *res=NULL;
569 char queryStr[BUFFMAXLN];
570 char* mailTiming=NULL;
572 /* set default values */
573 mailAddress[0]=limitDate[0]='\0';
575 /* if do not get result yet */
578 /* get mail send timing from conf file */
579 mailTiming = GetConfValue("Mail/Timing");
580 if(isNull(mailTiming)) return FALSE;
582 /* prepare query string */
583 /* [select mailAddress,limitDate,device from macaddrs
584 where ( date(now())=date(adddate(limitDate, interval -1 day))
585 OR date(now())=date(adddate(limitDate, interval -7 day)) )
586 AND (status='A' OR status='P') order by mailAddress,limitDate] */
587 snprintf(queryStr, BUFFMAXLN,
588 "select mailAddress,limitDate,device from macaddrs "
589 " where (%s) and (status='A' or status='P') "
590 " order by mailAddress,limitDate", mailTiming);
591 /* mailTiming is a condition string defined in conf file */
594 if (mysql_query(&mysql, queryStr)){
595 err_msg("ERR at %s#%d: mysql query[%s]: %s",__FILE__,__LINE__,queryStr,
596 mysql_error(&mysql));
601 res = mysql_store_result(&mysql);
604 /* output table name */
605 row = mysql_fetch_row(res);
607 /* if found, return values */
609 strlcpy(mailAddress, row[0], BUFFMAXLN);
610 strlcpy(limitDate, row[1], WORDMAXLN);
611 strlcpy(device, row[2], WORDMAXLN);
614 /* if not found, free memory area */
616 mysql_free_result(res);
621 /*******************************************
622 get the date corresponding to ShowLogAfter in conf file
623 *******************************************/
624 int getTimeRangeToShowLog(char* beginTime, char* endTime, int* dateCount){
626 static MYSQL_RES *res=NULL;
628 char queryStr[BUFFMAXLN];
630 char countStr[WORDMAXLN];
632 /* get conf value for beginning day for listing */
633 showLogAfter=GetConfValue("ShowLogAfter");
634 if(isNull(showLogAfter)) return FALSE;
636 /* set default values */
641 /* if do not get result yet */
644 /* prepare query string */
645 /* select (adddate(now(), interval -1 month)),
647 datediff(now(),(adddate(now(), interval -1 month))) + 1; */
648 snprintf(queryStr, BUFFMAXLN,
649 "select (%s), now(), datediff(now(),(%s)) + 1",
650 showLogAfter, showLogAfter);
653 if (mysql_query(&mysql, queryStr)){
654 err_msg("ERR at %s#%d: mysql query[%s]: %s",__FILE__,__LINE__,queryStr,
655 mysql_error(&mysql));
660 res = mysql_store_result(&mysql);
663 /* output table name */
664 row = mysql_fetch_row(res);
666 /* if found, return values */
668 strlcpy(beginTime, row[0], WORDMAXLN);
669 strlcpy(endTime, row[1], WORDMAXLN);
670 strlcpy(countStr, row[2], WORDMAXLN);
671 *dateCount=atoi(countStr);
674 /* if not found, free memory area */
676 mysql_free_result(res);
681 /********************************************
682 rename the device name for indicated mac address
683 ********************************************/
684 int renameDeviceNameInMngDb(char* macAddr, char* nameStr){
686 char queryStr[BUFFMAXLN];
688 /* prepare query string */
689 snprintf(queryStr, BUFFMAXLN,
690 "update macaddrs set device='%s' "
691 " where (status='A' or status='P') and macAddress='%s'",
695 if (mysql_query(&mysql, queryStr)){
696 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
697 mysql_error(&mysql));
703 /********************************************
704 rename the mail address for indicated mac address
705 ********************************************/
706 int renameMailAddressInMngDb(char* macAddr, char* mailStr){
708 char queryStr[BUFFMAXLN];
710 /* prepare query string */
711 snprintf(queryStr, BUFFMAXLN,
712 "update macaddrs set mailAddress='%s' "
713 " where (status='A' or status='P') and macAddress='%s'",
717 if (mysql_query(&mysql, queryStr)){
718 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
719 mysql_error(&mysql));
725 /********************************************
726 Register or Update MacAddress which is unlinked to user
727 ********************************************/
728 int regOrUpNobodyMacAddr(char* macAddress){
732 /* macAddress in inactive status cannot be modified */
733 if(IsMacAddrStatusInactiveInMngDb(macAddress)) return FALSE;
735 /* if mac is already registered, update it */
736 if(IsMacAddrFoundInMngDb(macAddress)){
737 if(RenewMacAddrInMngDb(macAddress)){
738 PutMacModifyLogToMngDb("?", "", macAddress, 'E'); /*(userId,extraId,.)*/
743 /* if mac is not yet registered, register it */
745 if(RegistMacAddrToMngDb(macAddress,"?","?","","")){ /*(dev,user,ext,mail) */
746 PutMacModifyLogToMngDb("?","", macAddress, 'R'); /* (userId,extraId,.) */
753 /******************************************
754 Is the macAddr in INACTIVE('I') status
755 ******************************************/
756 int isMacAddrStatusInactiveInMngDb(char* macAddr){
760 char queryStr[BUFFMAXLN];
763 /* prepare query string */
764 snprintf(queryStr, BUFFMAXLN,
765 "select * from macaddrs "
766 " where macAddress='%s' and status='I'",
770 if (mysql_query(&mysql, queryStr)){
771 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
772 mysql_error(&mysql));
777 res = mysql_store_result(&mysql);
779 /* output table name */
780 row = mysql_fetch_row(res);
782 /* if found, return true */
783 if(row!=NULL) ret=TRUE;
785 /* if not found, return false */
788 mysql_free_result(res);
792 /********************************************
793 routines for debugging output
794 ********************************************/
798 if(debug>1) err_msg("DEBUG:=>initMngDb()");
800 if(debug>1) err_msg("DEBUG:(%d)<=initMngDb()",ret);
803 void CloseMngDb(void){
804 if(debug>1) err_msg("DEBUG:=>closeMngDb()");
806 if(debug>1) err_msg("DEBUG:<=closeMngDb()");
809 int GetNextMacAddrFromMngDb(char* userId, char* extraId, char* macAddress, char* deviceName, char* entryDate, char* limitDate, char* status, char* mailAddress){
811 if(debug>1) err_msg("DEBUG:=>getNextMacAddrFromMngDb(%s,%s)",userId,extraId);
812 ret=getNextMacAddrFromMngDb(userId,extraId,macAddress,deviceName,
813 entryDate,limitDate, status,mailAddress);
814 if(debug>1) err_msg("DEBUG:(%d)<=getNextMacAddrFromMngDb(,,%s,%s,%s,%s,%s,%s)",
815 ret,macAddress,deviceName,entryDate,limitDate,status,mailAddress);
819 int RegistMacAddrToMngDb(char* macAddr, char* deviceName, char* userId, char* extraId, char* mailAddress){
821 if(debug>1) err_msg("DEBUG:=>registMacAddrToMngDb(%s,%s,%s,%s,%s)",
822 macAddr,deviceName,userId,extraId,mailAddress);
823 ret=registMacAddrToMngDb(macAddr,deviceName,userId,extraId, mailAddress);
824 if(debug>1) err_msg("DEBUG:(%d)<=registMacAddrToMngDb( )",ret);
828 int IsMacAddrFoundInMngDb(char* macAddr){
830 if(debug>1) err_msg("DEBUG:=>isMacAddrFoundInMngDb(%s)", macAddr);
831 ret=isMacAddrFoundInMngDb(macAddr);
832 if(debug>1) err_msg("DEBUG:(%d)<=isMacAddrFoundInMngDb( )",ret);
836 int CountMacAddrsForUserInMngDb(char* userId, char* extraId){
838 if(debug>1) err_msg("DEBUG:=>countMacAddrsForUserInMngDb(%s,%s)",
840 ret=countMacAddrsForUserInMngDb(userId,extraId);
841 if(debug>1) err_msg("DEBUG:(%d)<=countMacAddrsForUserInMngDb( )",ret);
845 int PutMacModifyLogToMngDb(char* userId, char* extraId, char* macAddr, char modifyType){
847 if(debug>1) err_msg("DEBUG:=>putMacModifyLogToMngDb(%s,%s,%s,%c)",
848 userId,extraId,macAddr,modifyType);
849 ret=putMacModifyLogToMngDb(userId,extraId,macAddr,modifyType);
850 if(debug>1) err_msg("DEBUG:(%d)<=putMacModifyLogToMngDb( )",ret);
854 int GetNicVendorFromMngDb(char* macAddress, char* vendor, int bufferLength){
856 if(debug>1) err_msg("DEBUG:=>getNicVendorFromMngDb(%s,,%d)",
857 macAddress, bufferLength);
858 ret=getNicVendorFromMngDb(macAddress, vendor, bufferLength);
859 if(debug>1) err_msg("DEBUG:(%d)<=getNicVendorFromMngDb(%s)",ret, vendor);
864 int CountMacModifyPerDayInMngDb(char* userId, char* extraId, char* macAddress){
866 if(debug>1) err_msg("DEBUG:=>countMacModifyPerDayInMngDb(%s,%s,%s)",
867 userId,extraId,macAddress);
868 ret=countMacModifyPerDayInMngDb(userId,extraId,macAddress);
869 if(debug>1) err_msg("DEBUG:(%d)<=countMacModifyPerDayInMngDb( )",ret);
873 int DelMacAddrFromMngDb(char* macAddr){
875 if(debug>1) err_msg("DEBUG:=>delMacAddrFromMngDb(%s)",macAddr);
876 ret=delMacAddrFromMngDb(macAddr);
877 if(debug>1) err_msg("DEBUG:(%d)<=delMacAddrFromMngDb( )",ret);
881 int RenewMacAddrInMngDb(char* macAddr){
883 if(debug>1) err_msg("DEBUG:=>renewMacAddrInMngDb(%s)",macAddr);
884 ret=renewMacAddrInMngDb(macAddr);
885 if(debug>1) err_msg("DEBUG:(%d)<=renewMacAddrinMngDb( )",ret);
889 int PauseMacAddrInMngDb(char* macAddr){
891 if(debug>1) err_msg("DEBUG:=>pauseMacAddrInMngDb(%s)",macAddr);
892 ret=pauseMacAddrInMngDb(macAddr);
893 if(debug>1) err_msg("DEBUG:(%d)<=pauseMacAddrinMngDb( )",ret);
897 int IsSessionFoundInMngDb(char* macAddr){
899 if(debug>1) err_msg("DEBUG:=>isSessionFoundInMngDb(%s)",macAddr);
900 ret=isSessionFoundInMngDb(macAddr);
901 if(debug>1) err_msg("DEBUG:(%d)<=isSessionFoundInMngDb( )",ret);
905 int GetNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr,
906 char* deviceName, char* openTime, char* closeTime, char* gatewayName){
908 if(debug>1) err_msg("DEBUG:=>getNextUsageLogFromMngDb(%s,%s)",userId,extraId);
909 ret=getNextUsageLogFromMngDb(userId,extraId,macAddr,deviceName,
910 openTime,closeTime,gatewayName);
911 if(debug>1) err_msg("DEBUG:(%d)<=getNextUsageLogFromMngDb(,,%s,%s,%s,%s,%s)",
912 ret,macAddr,deviceName,openTime,closeTime,gatewayName);
916 int GetNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char*device){
918 if(debug>1) err_msg("DEBUG:=>getnextMailAddressFromMngDb( )");
919 ret=getNextMailAddressFromMngDb(mailAddress, limitDate, device);
920 if(debug>1) err_msg("DEBUG:(%d)<=getNextMailAddressFromMngDb(%s,%s,%s)",
921 ret,mailAddress,limitDate,device);
925 int GetTimeRangeToShowLog(char* beginTime, char* endTime, int* dateCount){
927 if(debug>1) err_msg("DEBUG:=>getTimeRangeToShowLog( )");
928 ret=getTimeRangeToShowLog(beginTime, endTime, dateCount);
929 if(debug>1) err_msg("DEBUG:(%d)<=getTimeRangeToShowLog(%s,%s,%d)",
930 ret,beginTime,endTime,*dateCount);
934 int RenameDeviceNameInMngDb(char* macAddr, char* nameStr){
936 if(debug>1) err_msg("DEBUG:=>renameDevideNameInMngDb(%s,%s)",macAddr,nameStr);
937 ret=renameDeviceNameInMngDb(macAddr, nameStr);
938 if(debug>1) err_msg("DEBUG:(%d)<=renameDeviceNameInMngDb()",ret);
942 int RenameMailAddressInMngDb(char* macAddr, char* mailStr){
944 if(debug>1) err_msg("DEBUG:=>renameMailAddressInMngDb(%s,%s)",macAddr,mailStr);
945 ret=renameMailAddressInMngDb(macAddr, mailStr);
946 if(debug>1) err_msg("DEBUG:(%d)<=renameMailAddressInMngDb()",ret);
950 int RegOrUpNobodyMacAddr(char* macAddress){
952 if(debug>1) err_msg("DEBUG:=>regOrUpNobodyMacAddr(%s)",macAddress);
953 ret=regOrUpNobodyMacAddr(macAddress);
954 if(debug>1) err_msg("DEBUG:(%d)<=regOrUpNobodyMacAddr()",ret);
959 int IsMacAddrStatusInactiveInMngDb(char* macAddress){
961 if(debug>1) err_msg("DEBUG:=>isMacAddrStatusInactiveInMngDb(%s)",macAddress);
962 ret=isMacAddrStatusInactiveInMngDb(macAddress);
963 if(debug>1) err_msg("DEBUG:(%d)<=isMacAddrStatusInactiveInMngDb()",ret);