Changeset 1194
- Timestamp:
- 01/12/10 19:08:26 (14 years ago)
- Location:
- branches/monitor-improvement
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/monitor-improvement/csctapi/atr.c
r1140 r1194 153 153 atr->ib[pn][ATR_INTERFACE_BYTE_TD].present = TRUE; 154 154 (atr->TCK).present = ((TDi & 0x0F) != ATR_PROTOCOL_TYPE_T0); 155 if ((TDi & 0xF0) == 0) //last TDi byte156 break;157 155 if (pn >= ATR_MAX_PROTOCOLS) 158 156 return (ATR_MALFORMED); … … 284 282 atr->ib[pn][ATR_INTERFACE_BYTE_TD].present = TRUE; 285 283 (atr->TCK).present = ((TDi & 0x0F) != ATR_PROTOCOL_TYPE_T0); 286 if ((TDi & 0xF0) == 0) //last TDi byte287 break;288 284 if (pn >= ATR_MAX_PROTOCOLS) 289 285 return (ATR_MALFORMED); -
branches/monitor-improvement/csctapi/ifd_towitoko.c
r1189 r1194 620 620 if(n==0) 621 621 return IFD_TOWITOKO_IO_ERROR; 622 #endif 622 623 if ((buf[0] !=0x3B) && (buf[0] != 0x3F)) //irdeto S02 reports FD as first byte ?!? 624 buf[0] = 0x3B; 623 625 624 #ifdef SCI_DEV625 626 (*atr) = ATR_New (); 626 627 if(ATR_InitFromArray ((*atr), buf, n) == ATR_OK) … … 630 631 req_ts.tv_nsec = 50000000; 631 632 nanosleep (&req_ts, NULL); 632 #ifdef SCI_DEV633 633 if (ioctl(ifd->io->fd, IOCTL_SET_ATR_READY)<0) 634 634 return IFD_TOWITOKO_IO_ERROR; 635 #endif636 635 return IFD_TOWITOKO_OK; 637 636 } -
branches/monitor-improvement/csctapi/pps.c
r1189 r1194 138 138 if ((*length) <= 0 || !PPS_success) // If not by command, or PPS Exchange by command failed: Try PPS Exchange by ATR or Get parameters from ATR 139 139 { 140 int numprot = atr->pn ;//number of protocol lines in ATR140 int numprot = atr->pn-1;//number of protocol lines in ATR 141 141 BYTE tx; 142 cs_debug("ATR reports smartcard supports %i protocols:",numprot);142 cs_debug("ATR reports %i protocol lines:",numprot); 143 143 int i,point; 144 144 char txt[50]; … … 147 147 OffersT[i] = FALSE; 148 148 for (i=1; i<= numprot; i++) { 149 sprintf(txt,"Protocol %01i: ",i); 150 point = 12; 149 point = 0; 151 150 if (ATR_GetInterfaceByte (atr, i, ATR_INTERFACE_BYTE_TA, &tx) == ATR_OK) { 152 151 sprintf((char *)txt+point,"TA%i=%02X ",i,tx); … … 211 210 else { //negotiable mode 212 211 213 bool NeedsPTS = ((pps->parameters.t != 14) && (numprottype > 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255)); //needs PTS according to ISO 7816 , SCI gets stuck on our PTS 214 if (NeedsPTS) { 215 // PTSS PTS0 PTS1 PTS2 PTS3 PCK 216 // PTSS PTS0 PTS1 PCK 217 BYTE req[] = { 0xFF, 0x10, 0x00, 0x00 }; //we currently do not support PTS2, standard guardtimes 218 219 int p; 220 for (p=1; p<=numprot; p++) { 221 ATR_GetProtocolType(atr,p,&(pps->parameters.t)); 212 bool NeedsPTS = ((pps->parameters.t != 14) && (numprottype > 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255)); //needs PTS according to ISO 7816 , SCI gets stuck on our PTS 213 if (NeedsPTS) { 214 // PTSS PTS0 PTS1 PTS2 PTS3 PCK 215 // PTSS PTS0 PTS1 PCK 216 BYTE req[] = { 0xFF, 0x10, 0x00, 0x00 }; //we currently do not support PTS2, standard guardtimes 222 217 req[1]=0x10 | pps->parameters.t; //PTS0 always flags PTS1 to be sent always 223 if (ATR_GetInterfaceByte (atr, p, ATR_INTERFACE_BYTE_TA, &req[2]) != ATR_OK) //PTS1218 if (ATR_GetInterfaceByte (atr, 1, ATR_INTERFACE_BYTE_TA, &req[2]) != ATR_OK) //PTS1 224 219 req[2] = 0x11; //defaults FI and DI to 1 225 220 //req[3]=PPS_GetPCK(req,sizeof(req)-1); will be set by PPS_Exchange … … 231 226 pps->parameters.d = (double) (atr_d_table[DI]); 232 227 PPS_success = TRUE; 233 protocol_selected = p; 234 cs_debug("PTS Succesfull, selected protocol %i: T%i, F=%.0f, D=%.6f, N=%.0f\n", protocol_selected, pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 235 break; 228 cs_debug("PTS Succesfull, selected protocol: T%i, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 236 229 } 237 230 else 238 cs_ddump(req,4,"PTS Failure for protocol %i, response:",p); 239 } 240 } 241 242 //FIXME Currently InitICC sets baudrate to 9600 for all T14 cards (=no switching); 243 //When for SCI, T14 protocol, TA1 is obeyed, this goes OK for mosts devices, but somehow on DM7025 Sky S02 card goes wrong when setting ETU (ok on DM800/DM8000) 244 if (!PPS_success) {//last PPS not succesfull 245 BYTE TA1; 246 if (ATR_GetInterfaceByte (atr, 1 , ATR_INTERFACE_BYTE_TA, &TA1) == ATR_OK) { 247 pps->parameters.FI = TA1 >> 4; 248 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 249 } 250 else { //do not obey TA1 251 pps->parameters.FI = ATR_DEFAULT_FI; 252 pps->parameters.d = ATR_DEFAULT_D; 253 } 254 ATR_GetProtocolType (atr, 1, &(pps->parameters.t)); 255 protocol_selected = 1; 256 257 if (NeedsPTS) { 258 if ((pps->parameters.d == 32) || (pps->parameters.d == 12) || (pps->parameters.d == 20)) 259 pps->parameters.d = 0; //behave conform "old" atr_d_table; viaccess cards that fail PTS need this 260 } 261 /////Here all non-ISO behaviour 262 /////End all non-ISO behaviour 263 264 cs_debug("No PTS %s, selected protocol 1: T%i, F=%.0f, D=%.6f, N=%.0f\n", NeedsPTS?"happened":"needed", pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 265 } 231 cs_ddump(req,4,"PTS Failure, response:"); 232 } 233 234 //FIXME Currently InitICC sets baudrate to 9600 for all T14 cards (=no switching); 235 //When for SCI, T14 protocol, TA1 is obeyed, this goes OK for mosts devices, but somehow on DM7025 Sky S02 card goes wrong when setting ETU (ok on DM800/DM8000) 236 if (!PPS_success) {//last PPS not succesfull 237 BYTE TA1; 238 if (ATR_GetInterfaceByte (atr, 1 , ATR_INTERFACE_BYTE_TA, &TA1) == ATR_OK) { 239 pps->parameters.FI = TA1 >> 4; 240 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 241 } 242 else { //do not obey TA1 243 pps->parameters.FI = ATR_DEFAULT_FI; 244 pps->parameters.d = ATR_DEFAULT_D; 245 } 246 ATR_GetProtocolType (atr, 1, &(pps->parameters.t)); 247 protocol_selected = 1; 248 249 if (NeedsPTS) { 250 if ((pps->parameters.d == 32) || (pps->parameters.d == 12) || (pps->parameters.d == 20)) 251 pps->parameters.d = 0; //behave conform "old" atr_d_table; viaccess cards that fail PTS need this 252 } 253 /////Here all non-ISO behaviour 254 /////End all non-ISO behaviour 255 256 cs_debug("No PTS %s, selected protocol T%i, F=%.0f, D=%.6f, N=%.0f\n", NeedsPTS?"happened":"needed", pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 257 } 266 258 }//end negotiable mode 267 259 }//end length<0 … … 468 460 469 461 } 470 else471 462 #elif COOL 472 463 if(pps->icc->ifd->io->com==RTYP_SCI) { … … 479 470 return PPS_OK; 480 471 } 481 else482 472 #endif 483 473 { -
branches/monitor-improvement/module-monitor.c
r1192 r1194 7 7 #endif 8 8 9 static int auth=0;9 static int auth = 0; 10 10 11 11 static void monitor_check_ip() … … 230 230 } 231 231 232 int cs_idx2ridx(int idx) 233 { 234 int i; 235 for (i=0; i<CS_MAXREADER; i++) 236 if (reader[i].cs_idx==idx) 237 return(i); 238 return(-1); 239 } 240 241 char *monitor_get_srvname(int id) 242 { 243 struct s_srvid *this=cfg->srvid; 244 static char name[83]; 245 for (name[0]=0; this && (!name[0]); this=this->next) 246 if (this->srvid==id) 247 strncpy(name, this->name, 32); 248 if (!name[0]) sprintf(name, "[%04X]", id); 249 if (!id) name[0]='\0'; 250 return(name); 232 int cs_idx2ridx(int idx){ 233 int i; 234 for (i = 0; i < CS_MAXREADER; i++) 235 if (reader[i].cs_idx==idx) 236 return(i); 237 return(-1); 238 } 239 240 char *monitor_get_srvname(int id){ 241 struct s_srvid *this = cfg->srvid; 242 static char name[83]; 243 for (name[0] = 0; this && (!name[0]); this = this->next) 244 if (this->srvid == id) 245 strncpy(name, this->name, 32); 246 if (!name[0]) sprintf(name, "[%04X]", id); 247 if (!id) name[0] = '\0'; 248 return(name); 251 249 } 252 250 … … 290 288 } 291 289 292 static char *monitor_client_info(char id, int i) 293 { 294 static char sbuf[256]; 295 296 sbuf[0]='\0'; 297 if (client[i].pid) 298 { 299 char ldate[16], ltime[16], *usr; 300 int lsec, isec, cnr, con, cau; 301 time_t now; 302 struct tm *lt; 303 now=time((time_t)0); 304 305 if ((cfg->mon_hideclient_to <= 0) || 306 (((now-client[i].lastecm))<cfg->mon_hideclient_to) || 307 (((now-client[i].lastemm))<cfg->mon_hideclient_to) || 308 (client[i].typ!='c')) 309 { 310 lsec=now-client[i].login; 311 isec=now-client[i].last; 312 usr=client[i].usr; 313 if (((client[i].typ=='r') || (client[i].typ=='p')) && 314 (con=cs_idx2ridx(i))>=0) 315 usr=reader[con].label; 316 if (client[i].dup) 317 con=2; 318 else 319 if ((client[i].tosleep) && 320 (now-client[i].lastswitch>client[i].tosleep)) 321 con=1; 322 else 323 con=0; 324 if (i-cdiff>0) 325 cnr=i-cdiff; 326 else 327 cnr=(i>1) ? i-1 : 0; 328 if( (cau=client[i].au+1) ) 329 if ((now-client[i].lastemm)/60>cfg->mon_aulow) 330 cau=-cau; 331 lt=localtime(&client[i].login); 332 sprintf(ldate, "%2d.%02d.%02d", 333 lt->tm_mday, lt->tm_mon+1, lt->tm_year % 100); 334 sprintf(ltime, "%2d:%02d:%02d", 335 lt->tm_hour, lt->tm_min, lt->tm_sec); 336 sprintf(sbuf, "[%c--CCC]%d|%c|%d|%s|%d|%d|%s|%d|%s|%s|%s|%d|%04X:%04X|%s|%d|%d\n", 337 id, client[i].pid, client[i].typ, cnr, usr, cau, client[i].crypted, 338 cs_inet_ntoa(client[i].ip), client[i].port, monitor_get_proto(i), 339 ldate, ltime, lsec, client[i].last_caid, client[i].last_srvid, 340 monitor_get_srvname(client[i].last_srvid), isec, con); 341 } 342 } 343 return(sbuf); 344 } 345 346 static void monitor_process_info() 347 { 348 int i; 349 time_t now; 350 351 now=time((time_t)0); 352 for (i=0; i<CS_MAXPID; i++){ 353 if ((cfg->mon_hideclient_to <= 0) || 354 ((now-client[i].lastecm)<cfg->mon_hideclient_to) || 355 ((now-client[i].lastemm)<cfg->mon_hideclient_to) || 356 (client[i].typ!='c')) 357 if (client[i].pid) { 358 if ((client[cs_idx].monlvl<2) && (client[i].typ!='s')) { 359 if ((strcmp(client[cs_idx].usr, client[i].usr)) || ((client[i].typ!='c') && (client[i].typ!='m'))) 360 continue; 361 } 362 monitor_send_info(monitor_client_info('I', i), 0); 290 static char *monitor_client_info(char id, int i){ 291 static char sbuf[256]; 292 sbuf[0] = '\0'; 293 294 if (client[i].pid){ 295 char ldate[16], ltime[16], *usr; 296 int lsec, isec, cnr, con, cau; 297 time_t now; 298 struct tm *lt; 299 now=time((time_t)0); 300 301 if ((cfg->mon_hideclient_to <= 0) || 302 (now-client[i].lastecm < cfg->mon_hideclient_to) || 303 (now-client[i].lastemm < cfg->mon_hideclient_to) || 304 (client[i].typ != 'c')) 305 { 306 lsec=now-client[i].login; 307 isec=now-client[i].last; 308 usr=client[i].usr; 309 if (((client[i].typ == 'r') || (client[i].typ == 'p')) && (con=cs_idx2ridx(i)) >= 0) 310 usr=reader[con].label; 311 if (client[i].dup) 312 con=2; 313 else 314 if ((client[i].tosleep) && (now-client[i].lastswitch>client[i].tosleep)) 315 con = 1; 316 else 317 con = 0; 318 if (i - cdiff > 0) 319 cnr = i - cdiff; 320 else 321 cnr=(i > 1) ? i - 1 : 0; 322 if( (cau = client[i].au + 1) ) 323 if ((now-client[i].lastemm) /60 > cfg->mon_aulow) 324 cau=-cau; 325 lt = localtime(&client[i].login); 326 sprintf(ldate, "%2d.%02d.%02d", lt->tm_mday, lt->tm_mon+1, lt->tm_year % 100); 327 sprintf(ltime, "%2d:%02d:%02d", lt->tm_hour, lt->tm_min, lt->tm_sec); 328 sprintf(sbuf, "[%c--CCC]%d|%c|%d|%s|%d|%d|%s|%d|%s|%s|%s|%d|%04X:%04X|%s|%d|%d\n", 329 id, client[i].pid, client[i].typ, cnr, usr, cau, client[i].crypted, 330 cs_inet_ntoa(client[i].ip), client[i].port, monitor_get_proto(i), 331 ldate, ltime, lsec, client[i].last_caid, client[i].last_srvid, 332 monitor_get_srvname(client[i].last_srvid), isec, con); 333 } 334 } 335 return(sbuf); 336 } 337 338 static void monitor_process_info(){ 339 int i; 340 time_t now = time((time_t)0); 341 342 for (i = 0; i < CS_MAXPID; i++){ 343 if ((cfg->mon_hideclient_to <= 0) || 344 ( now-client[i].lastecm < cfg->mon_hideclient_to) || 345 ( now-client[i].lastemm < cfg->mon_hideclient_to) || 346 ( client[i].typ != 'c')){ 347 if (client[i].pid) { 348 if ((client[cs_idx].monlvl < 2) && (client[i].typ != 's')) { 349 if ((strcmp(client[cs_idx].usr, client[i].usr)) || 350 ((client[i].typ != 'c') && (client[i].typ != 'm'))) 351 continue; 352 } 353 monitor_send_info(monitor_client_info('I', i), 0); 363 354 } 364 } 365 monitor_send_info(NULL, 1); 366 } 367 368 static void monitor_send_details(char *txt, int pid) 369 { 370 char buf[256]; 371 snprintf(buf, 255, "[D-----]%d|%s\n", pid, txt); 372 monitor_send_info(buf, 0); 373 } 374 375 static void monitor_send_details_version() 376 { 377 char buf[256]; 378 sprintf(buf, "[V-0000]version=%s, build=%s, system=%s%s\n", CS_VERSION_X, CS_SVN_VERSION, cs_platform(buf+100), buf+200); 379 monitor_send_info(buf, 1); 380 } 381 382 static void monitor_process_details_master(char *buf, int pid) 383 { 384 if (cfg->nice!=99) 385 sprintf(buf+200, ", nice=%d", cfg->nice); 386 else 387 buf[200]='\0'; 388 sprintf(buf, "version=%s#%s, system=%s%s", CS_VERSION_X, CS_SVN_VERSION, cs_platform(buf+100), buf+200); 389 monitor_send_details(buf, pid); 390 391 sprintf(buf, "max. clients=%d, client max. idle=%ld sec", CS_MAXPID-2, cfg->cmaxidle); 392 monitor_send_details(buf, pid); 393 394 if( cfg->max_log_size ) 395 sprintf(buf+200, "%d Kb", cfg->max_log_size); 396 else 397 strcpy(buf+200, "unlimited"); 398 sprintf(buf, "max. logsize=%s", buf+200); 399 monitor_send_details(buf, pid); 400 401 sprintf(buf, "client timeout=%lu ms, cache delay=%ld ms", cfg->ctimeout, cfg->delay); 402 monitor_send_details(buf, pid); 355 } 356 } 357 monitor_send_info(NULL, 1); 358 } 359 360 static void monitor_send_details(char *txt, int pid){ 361 char buf[256]; 362 snprintf(buf, 255, "[D-----]%d|%s\n", pid, txt); 363 monitor_send_info(buf, 0); 364 } 365 366 static void monitor_send_details_version(){ 367 char buf[256]; 368 sprintf(buf, "[V-0000]version=%s, build=%s, system=%s%s\n", CS_VERSION_X, CS_SVN_VERSION, cs_platform(buf + 100), buf + 200); 369 monitor_send_info(buf, 1); 370 } 371 372 static void monitor_process_details_master(char *buf, int pid){ 373 if (cfg->nice != 99) 374 sprintf(buf + 200, ", nice=%d", cfg->nice); 375 else 376 buf[200] = '\0'; 377 sprintf(buf, "version=%s#%s, system=%s%s", CS_VERSION_X, CS_SVN_VERSION, cs_platform(buf + 100), buf + 200); 378 monitor_send_details(buf, pid); 379 380 sprintf(buf, "max. clients=%d, client max. idle=%ld sec", CS_MAXPID - 2, cfg->cmaxidle); 381 monitor_send_details(buf, pid); 382 383 if( cfg->max_log_size ) 384 sprintf(buf + 200, "%d Kb", cfg->max_log_size); 385 else 386 strcpy(buf + 200, "unlimited"); 387 sprintf(buf, "max. logsize=%s", buf + 200); 388 monitor_send_details(buf, pid); 389 390 sprintf(buf, "client timeout=%lu ms, cache delay=%ld ms", cfg->ctimeout, cfg->delay); 391 monitor_send_details(buf, pid); 403 392 404 393 //#ifdef CS_NOSHM … … 411 400 412 401 #ifdef CS_RDR_INIT_HIST 413 static void monitor_process_details_reader(int pid, int idx) 414 { 415 int r_idx; 416 char *p; 417 if ((r_idx=cs_idx2ridx(idx))>=0) 418 for (p=(char *)reader[r_idx].init_history; *p; p+=strlen(p)+1) 419 monitor_send_details(p, pid); 420 else 421 monitor_send_details("Missing reader index !", pid); 402 static void monitor_process_details_reader(int pid, int idx){ 403 int r_idx; 404 char *p; 405 if ((r_idx=cs_idx2ridx(idx))>=0) 406 for (p=(char *)reader[r_idx].init_history; *p; p+=strlen(p)+1) 407 monitor_send_details(p, pid); 408 else 409 monitor_send_details("Missing reader index !", pid); 422 410 } 423 411 #endif 424 412 425 static void monitor_process_details(char *arg) 426 { 427 int pid, idx; 428 char sbuf[256]; 429 if (!arg) return; 430 if ((idx=idx_from_pid(pid=atoi(arg)))<0) 431 monitor_send_details("Invalid PID", pid); 432 else 433 { 434 monitor_send_info(monitor_client_info('D', idx), 0); 435 switch(client[idx].typ) 436 { 437 case 's': 438 monitor_process_details_master(sbuf, pid); 439 break; 440 case 'c': case 'm': 441 break; 442 case 'r': 413 static void monitor_process_details(char *arg){ 414 int pid, idx; 415 char sbuf[256]; 416 if (!arg) return; 417 if ((idx = idx_from_pid(pid = atoi(arg))) < 0) 418 monitor_send_details("Invalid PID", pid); 419 else 420 { 421 monitor_send_info(monitor_client_info('D', idx), 0); 422 switch(client[idx].typ) 423 { 424 case 's': 425 monitor_process_details_master(sbuf, pid); 426 break; 427 case 'c': case 'm': 428 break; 429 case 'r': 443 430 #ifdef CS_RDR_INIT_HIST 444 431 monitor_process_details_reader(pid, idx); 445 432 #endif 446 break; 447 case 'p': 448 break; 449 } 450 } 451 monitor_send_info(NULL, 1); 452 } 453 454 static void monitor_send_login(void) 455 { 456 char buf[64]; 457 if (auth) 458 sprintf(buf, "[A-0000]1|%s logged in\n", client[cs_idx].usr); 459 else 460 strcpy(buf, "[A-0000]0|not logged in\n"); 461 monitor_send_info(buf, 1); 462 } 463 464 static void monitor_login(char *usr) 465 { 466 char *pwd=NULL; 467 if ((usr) && (pwd=strchr(usr, ' '))) 468 *pwd++=0; 469 if (pwd) 470 monitor_auth_client(trim(usr), trim(pwd)); 471 else 472 monitor_auth_client(NULL, NULL); 473 monitor_send_login(); 474 } 475 476 static void monitor_logsend(char *flag) 477 { 433 break; 434 case 'p': 435 break; 436 } 437 } 438 monitor_send_info(NULL, 1); 439 } 440 441 static void monitor_send_login(void){ 442 char buf[64]; 443 if (auth) 444 sprintf(buf, "[A-0000]1|%s logged in\n", client[cs_idx].usr); 445 else 446 strcpy(buf, "[A-0000]0|not logged in\n"); 447 monitor_send_info(buf, 1); 448 } 449 450 static void monitor_login(char *usr){ 451 char *pwd=NULL; 452 if ((usr) && (pwd=strchr(usr, ' '))) 453 *pwd++=0; 454 if (pwd) 455 monitor_auth_client(trim(usr), trim(pwd)); 456 else 457 monitor_auth_client(NULL, NULL); 458 monitor_send_login(); 459 } 460 461 static void monitor_logsend(char *flag){ 478 462 #ifdef CS_LOGHISTORY 479 463 int i; 480 464 #endif 481 482 483 484 485 486 487 488 489 465 if (strcmp(flag, "on")) { 466 if (strcmp(flag, "onwohist")) { 467 client[cs_idx].log=0; 468 return; 469 } 470 } 471 472 if (client[cs_idx].log) // already on 473 return; 490 474 #ifdef CS_LOGHISTORY 491 if (!strcmp(flag, "on")){ 492 for (i=(*loghistidx+3) % CS_MAXLOGHIST; i!=*loghistidx; i=(i+1) % CS_MAXLOGHIST) 493 { 494 char *p_usr, *p_txt; 495 p_usr=(char *)(loghist+(i*CS_LOGHISTSIZE)); 496 p_txt=p_usr+32; 497 if ((p_txt[0]) && 498 ((client[cs_idx].monlvl>1) || (!strcmp(p_usr, client[cs_idx].usr)))) 499 { 500 char sbuf[8]; 501 sprintf(sbuf, "%03d", client[cs_idx].logcounter); 502 client[cs_idx].logcounter=(client[cs_idx].logcounter+1) % 1000; 503 memcpy(p_txt+4, sbuf, 3); 504 monitor_send(p_txt); 505 } 506 } 507 } 475 if (!strcmp(flag, "on")){ 476 for (i = (*loghistidx + 3) % CS_MAXLOGHIST; i != *loghistidx; i = (i + 1) % CS_MAXLOGHIST){ 477 char *p_usr, *p_txt; 478 p_usr=(char *)(loghist+(i*CS_LOGHISTSIZE)); 479 p_txt = p_usr + 32; 480 if ((p_txt[0]) && ((client[cs_idx].monlvl > 1) || (!strcmp(p_usr, client[cs_idx].usr)))) { 481 char sbuf[8]; 482 sprintf(sbuf, "%03d", client[cs_idx].logcounter); 483 client[cs_idx].logcounter=(client[cs_idx].logcounter + 1) % 1000; 484 memcpy(p_txt + 4, sbuf, 3); 485 monitor_send(p_txt); 486 } 487 } 488 } 508 489 #endif 509 client[cs_idx].log=1; 510 } 511 static void monitor_set_debuglevel(char *flag) 512 { 513 cs_dblevel^=atoi(flag); 514 kill(client[0].pid, SIGUSR1); 515 } 516 517 static void monitor_set_account(char *args) 518 { 490 client[cs_idx].log=1; 491 } 492 493 static void monitor_set_debuglevel(char *flag){ 494 cs_dblevel^=atoi(flag); 495 kill(client[0].pid, SIGUSR1); 496 } 497 498 static void monitor_set_account(char *args){ 519 499 struct s_auth *account; 520 500 char delimiter[] = " ="; … … 577 557 } 578 558 579 static void monitor_set_server(char *args) 580 { 559 static void monitor_set_server(char *args){ 581 560 char delimiter[] = "="; 582 561 char *ptr; … … 691 670 } 692 671 693 static void monitor_server() 694 { 695 int n; 696 client[cs_idx].typ='m'; 697 while (((n=process_input(mbuf, sizeof(mbuf), cfg->cmaxidle))>=0) && 698 monitor_process_request((char *)mbuf)); 699 cs_disconnect_client(); 700 } 701 702 void module_monitor(struct s_module *ph) 703 { 704 static PTAB ptab; 705 ptab.ports[0].s_port = cfg->mon_port; 706 ph->ptab = &ptab; 707 ph->ptab->nports = 1; 708 709 if (cfg->mon_aulow<1) 710 cfg->mon_aulow=30; 711 strcpy(ph->desc, "monitor"); 712 ph->type=MOD_CONN_UDP; 713 ph->multi=0; 714 ph->watchdog=1; 715 ph->s_ip=cfg->mon_srvip; 716 ph->s_handler=monitor_server; 717 ph->recv=monitor_recv; 672 static void monitor_server(){ 673 int n; 674 client[cs_idx].typ='m'; 675 while (((n = process_input(mbuf, sizeof(mbuf), cfg->cmaxidle)) >= 0) && monitor_process_request((char *)mbuf)); 676 cs_disconnect_client(); 677 } 678 679 void module_monitor(struct s_module *ph){ 680 static PTAB ptab; 681 ptab.ports[0].s_port = cfg->mon_port; 682 ph->ptab = &ptab; 683 ph->ptab->nports = 1; 684 685 if (cfg->mon_aulow < 1) 686 cfg->mon_aulow = 30; 687 strcpy(ph->desc, "monitor"); 688 ph->type=MOD_CONN_UDP; 689 ph->multi = 0; 690 ph->watchdog = 1; 691 ph->s_ip = cfg->mon_srvip; 692 ph->s_handler = monitor_server; 693 ph->recv = monitor_recv; 718 694 // ph->send_dcw=NULL; 719 695 }
Note:
See TracChangeset
for help on using the changeset viewer.