1 /**************************************************
2 OpengateM - MAC address authentication system
4 module to control management database that includes following tables
5 list of mac addresses and their owners
7 this database is implemented with MySql
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 /*****************************/
38 /* set parameters read from conf file */
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 /**********************************/
69 /*close management db */
70 /**********************************/
71 void closeMngDb(void){
77 /*********************************************************/
78 /* get nic vendor from table nicvendors in management db */
79 /* macAddress:(in),vendor:(out),bufferLength:(in) */
80 /*********************************************************/
81 int getNicVendorFromMngDb(char* macAddress, char* vendor, int bufferLength){
86 char queryStr[BUFFMAXLN];
87 char macHeader[ADDRMAXLN];
89 /* set default values (="?") */
93 /* prepare query string */
94 /* macHeader is first 3 bytes of macAddess that represents vender code */
95 /* macAddress="11:22:33:44:55:66" -> macHeader="11:22:33" */
96 strlcpy(macHeader, macAddress, ADDRMAXLN);
98 snprintf(queryStr, BUFFMAXLN,
99 "select org from nicvendors where oui='%s'",
103 if (mysql_query(&mysql, queryStr)){
104 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
105 mysql_error(&mysql));
108 res = mysql_use_result(&mysql);
110 /* get a row from query result */
111 row = mysql_fetch_row(res);
113 /* if not found, return false */
114 if(row==NULL) found=FALSE;
116 /* if found, get the vendor name */
118 strlcpy(vendor, row[0], bufferLength);
122 /* free memory area */
123 mysql_free_result(res);
127 /*************************************************/
128 /* The macAddr is already registered or not */
129 /* the row having status="D"(deleted) is ignored */
130 /* macAddr:(input) */
131 /*************************************************/
132 int isMacAddrFoundInMngDb(char* macAddr){
136 char queryStr[BUFFMAXLN];
139 /* prepare query string */
140 snprintf(queryStr, BUFFMAXLN,
141 "select * from macaddrs "
142 " where macAddress='%s' and status!='D'",
146 if (mysql_query(&mysql, queryStr)){
147 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
148 mysql_error(&mysql));
152 /* store query result */
153 res = mysql_store_result(&mysql);
155 /* get a row from query result */
156 row = mysql_fetch_row(res);
158 /* if found, return true */
159 if(row!=NULL) ret=TRUE;
161 /* if not found, return false */
164 /* free memory area */
165 mysql_free_result(res);
170 /******************************************************/
171 /* The count of registered mac addresses for the user */
172 /* the row having status="D"(deleted) is ignored */
173 /* all-args:(input) */
174 /******************************************************/
175 int countMacAddrsForUserInMngDb(char* userId, char* extraId){
179 char queryStr[BUFFMAXLN];
180 char countStr[WORDMAXLN];
183 /* prepare query string */
184 snprintf(queryStr, BUFFMAXLN,
185 "select count(*) from macaddrs "
186 " where userId='%s' and extraId='%s' and status!='D'",
190 if (mysql_query(&mysql, queryStr)){
191 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
192 mysql_error(&mysql));
196 /* store query result */
197 res = mysql_store_result(&mysql);
199 /* get a row from query result */
200 row = mysql_fetch_row(res);
202 /* if found, return the count */
204 strlcpy(countStr, row[0], WORDMAXLN);
205 count=atoi(countStr);
208 /* free memory area */
209 mysql_free_result(res);
214 /***********************************************************/
215 /* register mac address and the owner to the management db */
216 /* all-args:(input) */
217 /***********************************************************/
218 int registMacAddrToMngDb(char* macAddr, char* deviceName, char* userId, char* extraId, char* mailAddr){
220 char queryStr[BUFFMAXLN];
223 /* if alreay registered, return false */
224 if(IsMacAddrFoundInMngDb(macAddr)){
225 SetMessage(ExistentMacAddr);
229 /* if the count of devices for a user exceeds the limit(in conf), return false */
230 count=CountMacAddrsForUserInMngDb(userId,extraId);
231 if(count >= atoi(GetConfValue("MaxDevices"))){
232 SetMessage(DeviceCountOver);
236 /* prepare query string */
237 snprintf(queryStr, BUFFMAXLN,
238 "insert into macaddrs "
239 "(macAddress, status, device, userId, extraId, "
240 " entryDate, renewDate, limitDate, mailAddress) "
241 "values ('%s','A','%s', '%s', '%s', "
242 " now(), now(), %s, '%s')",
243 macAddr, deviceName, userId, extraId,
244 GetConfValue("LimitDate"), mailAddr);
247 if (mysql_query(&mysql, queryStr)){
248 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
249 mysql_error(&mysql));
256 /********************************************************/
257 /* get next mac address for the user from management db */
258 /* at first call, execute query and return first row */
259 /* from second call, return next row of previous query */
260 /* repeat until return=false (end of list, clear work) */
261 /* userId,extraId:(input), others:(output) */
262 /********************************************************/
263 int getNextMacAddrFromMngDb(char* userId, char* extraId, char* macAddress, char* deviceName, char* entryDate, char* limitDate, char* status, char* mailAddress){
265 static MYSQL_RES *res=NULL;
267 char queryStr[BUFFMAXLN];
269 /* set default values */
270 macAddress[0]=deviceName[0]=entryDate[0]=limitDate[0]='\0';
272 /* if do not get result yet */
275 /* prepare query string */
276 snprintf(queryStr, BUFFMAXLN,
277 "select macAddress, device, entryDate, limitDate, status, mailAddress "
278 "from macaddrs where userId='%s' and extraId='%s' and status!='D'",
282 if (mysql_query(&mysql, queryStr)){
283 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
284 mysql_error(&mysql));
289 res = mysql_store_result(&mysql);
292 /* output table name */
293 row = mysql_fetch_row(res);
295 /* if found, return values */
297 strlcpy(macAddress, row[0],ADDRMAXLN);
298 strlcpy(deviceName,row[1],WORDMAXLN);
299 strlcpy(entryDate,row[2],WORDMAXLN);
300 strlcpy(limitDate,row[3],WORDMAXLN);
301 strlcpy(status,row[4],WORDMAXLN);
302 strlcpy(mailAddress,row[5],BUFFMAXLN);
305 /* if not found, free memory area */
307 mysql_free_result(res);
313 /***************************************************/
314 /* write mac modification log to the management db */
315 /* all-args:(input) */
316 /***************************************************/
317 int putMacModifyLogToMngDb(char* userId, char* extraId, char* macAddr, char modifyType){
319 char queryStr[BUFFMAXLN];
321 /*** insert modify log ***/
322 /* prepare query string */
323 snprintf(queryStr, BUFFMAXLN,
324 "insert into macmodify "
325 "(userId, extraId, macAddress, modifyType, modifyDate) "
326 "values ('%s', '%s', '%s', '%c', now())",
327 userId, extraId, macAddr, modifyType);
330 if (mysql_query(&mysql, queryStr)){
331 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
332 mysql_error(&mysql));
335 /*** remove old log ***/
336 /* prepare query string */
337 snprintf(queryStr, BUFFMAXLN,
338 "delete from macmodify "
339 " where modifyDate < adddate(now(), interval -1 day) ");
342 if (mysql_query(&mysql, queryStr)){
343 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
344 mysql_error(&mysql));
351 /************************************************************/
352 /* The count of mac address modification in last 24 hours */
353 /* (the modification count is checked to cope with abuse) */
354 /* all-args:(input) */
355 /* indicate either of userID&extraId or macAddress to count */
356 /************************************************************/
357 int countMacModifyPerDayInMngDb(char* userId, char* extraId, char* macAddress){
361 char queryStr[BUFFMAXLN];
362 char countStr[WORDMAXLN];
365 /* prepare query string */
366 /* count for one macAddress if not null, elsecount for one userID)*/
367 if(!isNull(macAddress)){
368 snprintf(queryStr, BUFFMAXLN,
369 "select count(*) from macmodify "
370 " where macAddress='%s' and "
371 " modifyDate > adddate(now(), interval -1 day) ",
374 snprintf(queryStr, BUFFMAXLN,
375 "select count(*) from macmodify "
376 " where userId='%s' and extraId='%s' and "
377 " modifyDate > adddate(now(), interval -1 day) ",
382 if (mysql_query(&mysql, queryStr)){
383 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
384 mysql_error(&mysql));
388 /* store query result */
389 res = mysql_store_result(&mysql);
391 /* get a row from query result */
392 row = mysql_fetch_row(res);
394 /* if found, return count (if not, return large value for safe) */
396 strlcpy(countStr, row[0], WORDMAXLN);
397 count=atoi(countStr);
400 /* free memory area */
401 mysql_free_result(res);
406 /*********************************************************/
407 /* delete a mac address registered in the management db */
408 /* actuality, not delete row, but set the status="D" */
409 /* macAddr:(input) */
410 /*********************************************************/
411 int delMacAddrFromMngDb(char* macAddr){
413 char queryStr[BUFFMAXLN];
415 /* prepare query string */
416 /* don't touch device of status="I"(set Inactive by admin) */
417 snprintf(queryStr, BUFFMAXLN,
418 "update macaddrs set status='D',limitDate=now() "
419 " where macAddress='%s' and (status='A' or status='P')", macAddr);
422 if (mysql_query(&mysql, queryStr)){
423 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
424 mysql_error(&mysql));
430 /******************************************/
431 /* renew the limit date for a mac address */
432 /* in the management db */
433 /* macAddr:(input) */
434 /* LimitDate in conf file is a SQL string */
435 /* to make a future date */
436 /* eg, "adddate(now(),interval 1 month)" */
437 /******************************************/
438 int renewMacAddrInMngDb(char* macAddr){
440 char queryStr[BUFFMAXLN];
442 /* prepare query string */
443 /* don't touch device set as inactive by admin */
444 snprintf(queryStr, BUFFMAXLN,
445 "update macaddrs set status='A', renewDate=now(), limitDate=%s "
446 " where (status='A' or status='P') and macAddress='%s'",
447 GetConfValue("LimitDate"),macAddr);
450 if (mysql_query(&mysql, queryStr)){
451 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
452 mysql_error(&mysql));
458 /******************************************
459 pause the usage of the device for a mac address
460 registered in the management db
461 ******************************************/
462 int pauseMacAddrInMngDb(char* macAddr){
464 char queryStr[BUFFMAXLN];
466 /* prepare query string */
467 /* don't touch device set as inactive by admin */
468 snprintf(queryStr, BUFFMAXLN,
469 "update macaddrs set status='P' "
470 " where status='A' and macAddress='%s' and limitDate>now()",
474 if (mysql_query(&mysql, queryStr)){
475 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
476 mysql_error(&mysql));
482 /*******************************************
483 get next mail address near limit date
485 *******************************************/
486 int getNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char* device){
488 static MYSQL_RES *res=NULL;
490 char queryStr[BUFFMAXLN];
491 char* mailTiming=NULL;
493 /* set default values */
494 mailAddress[0]=limitDate[0]='\0';
496 /* if do not get result yet */
499 /* get mail send timing from conf file */
500 mailTiming = GetConfValue("Mail/Timing");
501 if(isNull(mailTiming)) return FALSE;
503 /* prepare query string */
504 /* [select mailAddress,limitDate,device from macaddrs
505 where ( date(now())=date(adddate(limitDate, interval -1 day))
506 OR date(now())=date(adddate(limitDate, interval -7 day)) )
507 AND (status='A' OR status='P') order by mailAddress,limitDate] */
508 snprintf(queryStr, BUFFMAXLN,
509 "select mailAddress,limitDate,device from macaddrs "
510 " where (%s) and (status='A' or status='P') "
511 " order by mailAddress,limitDate", mailTiming);
512 /* mailTiming is a condition string defined in conf file */
515 if (mysql_query(&mysql, queryStr)){
516 err_msg("ERR at %s#%d: mysql query[%s]: %s",__FILE__,__LINE__,queryStr,
517 mysql_error(&mysql));
522 res = mysql_store_result(&mysql);
525 /* output table name */
526 row = mysql_fetch_row(res);
528 /* if found, return values */
530 strlcpy(mailAddress, row[0], BUFFMAXLN);
531 strlcpy(limitDate, row[1], WORDMAXLN);
532 strlcpy(device, row[2], WORDMAXLN);
535 /* if not found, free memory area */
537 mysql_free_result(res);
542 /*******************************************
543 get the date corresponding to ShowLogAfter in conf file
544 *******************************************/
545 int getTimeRangeToShowLog(char* beginTime, char* endTime, int* dateCount){
547 static MYSQL_RES *res=NULL;
549 char queryStr[BUFFMAXLN];
551 char countStr[WORDMAXLN];
553 /* get conf value for beginning day for listing */
554 showLogAfter=GetConfValue("ShowLogAfter");
555 if(isNull(showLogAfter)) return FALSE;
557 /* set default values */
562 /* if do not get result yet */
565 /* prepare query string */
566 /* select (adddate(now(), interval -1 month)),
568 datediff(now(),(adddate(now(), interval -1 month))) + 1; */
569 snprintf(queryStr, BUFFMAXLN,
570 "select (%s), now(), datediff(now(),(%s)) + 1",
571 showLogAfter, showLogAfter);
574 if (mysql_query(&mysql, queryStr)){
575 err_msg("ERR at %s#%d: mysql query[%s]: %s",__FILE__,__LINE__,queryStr,
576 mysql_error(&mysql));
581 res = mysql_store_result(&mysql);
584 /* output table name */
585 row = mysql_fetch_row(res);
587 /* if found, return values */
589 strlcpy(beginTime, row[0], WORDMAXLN);
590 strlcpy(endTime, row[1], WORDMAXLN);
591 strlcpy(countStr, row[2], WORDMAXLN);
592 *dateCount=atoi(countStr);
595 /* if not found, free memory area */
597 mysql_free_result(res);
602 /********************************************
603 rename the device name for indicated mac address
604 ********************************************/
605 int renameDeviceNameInMngDb(char* macAddr, char* nameStr){
607 char queryStr[BUFFMAXLN];
609 /* prepare query string */
610 snprintf(queryStr, BUFFMAXLN,
611 "update macaddrs set device='%s' "
612 " where (status='A' or status='P') and macAddress='%s'",
616 if (mysql_query(&mysql, queryStr)){
617 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
618 mysql_error(&mysql));
624 /********************************************
625 rename the mail address for indicated mac address
626 ********************************************/
627 int renameMailAddressInMngDb(char* macAddr, char* mailStr){
629 char queryStr[BUFFMAXLN];
631 /* prepare query string */
632 snprintf(queryStr, BUFFMAXLN,
633 "update macaddrs set mailAddress='%s' "
634 " where (status='A' or status='P') and macAddress='%s'",
638 if (mysql_query(&mysql, queryStr)){
639 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
640 mysql_error(&mysql));
646 /********************************************
647 Register or Update MacAddress which is unlinked to user
648 ********************************************/
649 int regOrUpNobodyMacAddr(char* macAddress){
653 /* macAddress in inactive status cannot be modified */
654 if(IsMacAddrStatusInactiveInMngDb(macAddress)) return FALSE;
656 /* if mac is already registered, update it */
657 if(IsMacAddrFoundInMngDb(macAddress)){
658 if(RenewMacAddrInMngDb(macAddress)){
659 PutMacModifyLogToMngDb("?", "", macAddress, 'E'); /*(userId,extraId,.)*/
664 /* if mac is not yet registered, register it */
666 if(RegistMacAddrToMngDb(macAddress,"?","?","","")){ /*(dev,user,ext,mail) */
667 PutMacModifyLogToMngDb("?","", macAddress, 'R'); /* (userId,extraId,.) */
674 /******************************************
675 Is the macAddr in INACTIVE('I') status
676 ******************************************/
677 int isMacAddrStatusInactiveInMngDb(char* macAddr){
681 char queryStr[BUFFMAXLN];
684 /* prepare query string */
685 snprintf(queryStr, BUFFMAXLN,
686 "select * from macaddrs "
687 " where macAddress='%s' and status='I'",
691 if (mysql_query(&mysql, queryStr)){
692 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
693 mysql_error(&mysql));
698 res = mysql_store_result(&mysql);
700 /* output table name */
701 row = mysql_fetch_row(res);
703 /* if found, return true */
704 if(row!=NULL) ret=TRUE;
706 /* if not found, return false */
709 mysql_free_result(res);
713 /******************************************************/
714 /* Does the mac address belong to the userid@extraid */
715 /* all-args:(input) */
716 /* return value: true(1)=YES, false(0)=NO */
717 /******************************************************/
718 int doesMacAddrBelongToUser(char* macAddr, char* userId, char* extraId){
722 char queryStr[BUFFMAXLN];
723 char existsStr[WORDMAXLN];
726 /* prepare query string */
727 snprintf(queryStr, BUFFMAXLN,
728 "select exists(select * from macaddrs "
729 " where macAddress='%s' and userId='%s' "
730 " and extraId='%s' and status!='D') ",
731 macAddr, userId, extraId);
734 if (mysql_query(&mysql, queryStr)){
735 err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
736 mysql_error(&mysql));
740 /* store query result */
741 res = mysql_store_result(&mysql);
743 /* get a row from query result */
744 row = mysql_fetch_row(res);
746 /* if found, return the count */
748 strlcpy(existsStr, row[0], WORDMAXLN);
749 exists=atoi(existsStr);
752 /* free memory area */
753 mysql_free_result(res);
758 /********************************************
759 routines for debugging output
760 ********************************************/
764 if(debug>1) err_msg("DEBUG:=>initMngDb()");
766 if(debug>1) err_msg("DEBUG:(%d)<=initMngDb()",ret);
769 void CloseMngDb(void){
770 if(debug>1) err_msg("DEBUG:=>closeMngDb()");
772 if(debug>1) err_msg("DEBUG:<=closeMngDb()");
775 int GetNextMacAddrFromMngDb(char* userId, char* extraId, char* macAddress, char* deviceName, char* entryDate, char* limitDate, char* status, char* mailAddress){
777 if(debug>1) err_msg("DEBUG:=>getNextMacAddrFromMngDb(%s,%s)",userId,extraId);
778 ret=getNextMacAddrFromMngDb(userId,extraId,macAddress,deviceName,
779 entryDate,limitDate, status,mailAddress);
780 if(debug>1) err_msg("DEBUG:(%d)<=getNextMacAddrFromMngDb(,,%s,%s,%s,%s,%s,%s)",
781 ret,macAddress,deviceName,entryDate,limitDate,status,mailAddress);
785 int RegistMacAddrToMngDb(char* macAddr, char* deviceName, char* userId, char* extraId, char* mailAddress){
787 if(debug>1) err_msg("DEBUG:=>registMacAddrToMngDb(%s,%s,%s,%s,%s)",
788 macAddr,deviceName,userId,extraId,mailAddress);
789 ret=registMacAddrToMngDb(macAddr,deviceName,userId,extraId, mailAddress);
790 if(debug>1) err_msg("DEBUG:(%d)<=registMacAddrToMngDb( )",ret);
794 int IsMacAddrFoundInMngDb(char* macAddr){
796 if(debug>1) err_msg("DEBUG:=>isMacAddrFoundInMngDb(%s)", macAddr);
797 ret=isMacAddrFoundInMngDb(macAddr);
798 if(debug>1) err_msg("DEBUG:(%d)<=isMacAddrFoundInMngDb( )",ret);
802 int CountMacAddrsForUserInMngDb(char* userId, char* extraId){
804 if(debug>1) err_msg("DEBUG:=>countMacAddrsForUserInMngDb(%s,%s)",
806 ret=countMacAddrsForUserInMngDb(userId,extraId);
807 if(debug>1) err_msg("DEBUG:(%d)<=countMacAddrsForUserInMngDb( )",ret);
811 int PutMacModifyLogToMngDb(char* userId, char* extraId, char* macAddr, char modifyType){
813 if(debug>1) err_msg("DEBUG:=>putMacModifyLogToMngDb(%s,%s,%s,%c)",
814 userId,extraId,macAddr,modifyType);
815 ret=putMacModifyLogToMngDb(userId,extraId,macAddr,modifyType);
816 if(debug>1) err_msg("DEBUG:(%d)<=putMacModifyLogToMngDb( )",ret);
820 int GetNicVendorFromMngDb(char* macAddress, char* vendor, int bufferLength){
822 if(debug>1) err_msg("DEBUG:=>getNicVendorFromMngDb(%s,,%d)",
823 macAddress, bufferLength);
824 ret=getNicVendorFromMngDb(macAddress, vendor, bufferLength);
825 if(debug>1) err_msg("DEBUG:(%d)<=getNicVendorFromMngDb(%s)",ret, vendor);
830 int CountMacModifyPerDayInMngDb(char* userId, char* extraId, char* macAddress){
832 if(debug>1) err_msg("DEBUG:=>countMacModifyPerDayInMngDb(%s,%s,%s)",
833 userId,extraId,macAddress);
834 ret=countMacModifyPerDayInMngDb(userId,extraId,macAddress);
835 if(debug>1) err_msg("DEBUG:(%d)<=countMacModifyPerDayInMngDb( )",ret);
839 int DelMacAddrFromMngDb(char* macAddr){
841 if(debug>1) err_msg("DEBUG:=>delMacAddrFromMngDb(%s)",macAddr);
842 ret=delMacAddrFromMngDb(macAddr);
843 if(debug>1) err_msg("DEBUG:(%d)<=delMacAddrFromMngDb( )",ret);
847 int RenewMacAddrInMngDb(char* macAddr){
849 if(debug>1) err_msg("DEBUG:=>renewMacAddrInMngDb(%s)",macAddr);
850 ret=renewMacAddrInMngDb(macAddr);
851 if(debug>1) err_msg("DEBUG:(%d)<=renewMacAddrinMngDb( )",ret);
855 int PauseMacAddrInMngDb(char* macAddr){
857 if(debug>1) err_msg("DEBUG:=>pauseMacAddrInMngDb(%s)",macAddr);
858 ret=pauseMacAddrInMngDb(macAddr);
859 if(debug>1) err_msg("DEBUG:(%d)<=pauseMacAddrinMngDb( )",ret);
863 int GetNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char*device){
865 if(debug>1) err_msg("DEBUG:=>getnextMailAddressFromMngDb( )");
866 ret=getNextMailAddressFromMngDb(mailAddress, limitDate, device);
867 if(debug>1) err_msg("DEBUG:(%d)<=getNextMailAddressFromMngDb(%s,%s,%s)",
868 ret,mailAddress,limitDate,device);
872 int GetTimeRangeToShowLog(char* beginTime, char* endTime, int* dateCount){
874 if(debug>1) err_msg("DEBUG:=>getTimeRangeToShowLog( )");
875 ret=getTimeRangeToShowLog(beginTime, endTime, dateCount);
876 if(debug>1) err_msg("DEBUG:(%d)<=getTimeRangeToShowLog(%s,%s,%d)",
877 ret,beginTime,endTime,*dateCount);
881 int RenameDeviceNameInMngDb(char* macAddr, char* nameStr){
883 if(debug>1) err_msg("DEBUG:=>renameDevideNameInMngDb(%s,%s)",macAddr,nameStr);
884 ret=renameDeviceNameInMngDb(macAddr, nameStr);
885 if(debug>1) err_msg("DEBUG:(%d)<=renameDeviceNameInMngDb()",ret);
889 int RenameMailAddressInMngDb(char* macAddr, char* mailStr){
891 if(debug>1) err_msg("DEBUG:=>renameMailAddressInMngDb(%s,%s)",macAddr,mailStr);
892 ret=renameMailAddressInMngDb(macAddr, mailStr);
893 if(debug>1) err_msg("DEBUG:(%d)<=renameMailAddressInMngDb()",ret);
897 int RegOrUpNobodyMacAddr(char* macAddress){
899 if(debug>1) err_msg("DEBUG:=>regOrUpNobodyMacAddr(%s)",macAddress);
900 ret=regOrUpNobodyMacAddr(macAddress);
901 if(debug>1) err_msg("DEBUG:(%d)<=regOrUpNobodyMacAddr()",ret);
906 int IsMacAddrStatusInactiveInMngDb(char* macAddress){
908 if(debug>1) err_msg("DEBUG:=>isMacAddrStatusInactiveInMngDb(%s)",macAddress);
909 ret=isMacAddrStatusInactiveInMngDb(macAddress);
910 if(debug>1) err_msg("DEBUG:(%d)<=isMacAddrStatusInactiveInMngDb()",ret);
914 int DoesMacAddrBelongToUser(char* macAddr, char* userId, char* extraId){
916 if(debug>1) err_msg("DEBUG:=>doesMacAddrBelongToUser(%s,%s,%s)",
917 macAddr,userId,extraId);
918 ret=doesMacAddrBelongToUser(macAddr,userId,extraId);
919 if(debug>1) err_msg("DEBUG:(%d)<=doesMacAddrBelongToUser( )",ret);