Snort 에서 thread 사용에 대해 ???????
Snort 1.8에서는
461 #ifdef USE_PTHREADS
462 /*
463 * With pthreads each interface gets a thread of its own.
464 *
465 */
466 for(i = 0; i < ifr_count; i++)
467 {
468 pthread_create(&pt[i], NULL, InterfaceThread, NULL);
469 }
470
471 while(1)
472 {
473 sleep(10);
474 }
475
476 #else
477 /* Without pthreads one interface goes in main thread */
478 InterfaceThread(NULL);
479 #endif
이부분처럼 쓰레드를 ifr갯수만큼 생성을 했습니다.
그러나 Snort 2.1 에서는
InterfaceThread(NULL);
이부분만 있고 pthread_create 부분이 없어졌는데
그렇다면 2.1 에서는 pthread_create를 사용하지 않는 다는 것인가요 ?
void *InterfaceThread(void *arg)
{
static int intnum = 0;
int myint;
struct timeval starttime;
struct timeval endtime;
struct timeval difftime;
struct timezone tz;
myint = intnum;
intnum++;
bzero((char *) &tz, sizeof(tz));
gettimeofday(&starttime, &tz);
/* Read all packets on the device. Continue until cnt packets read */
if(pcap_loop(pd, pv.pkt_cnt, (pcap_handler) ProcessPacket, NULL) < 0)
{
if(pv.daemon_flag)
syslog(LOG_CONS | LOG_DAEMON, "pcap_loop: %s", pcap_geterr(pd));
else
ErrorMessage("pcap_loop: %s\n", pcap_geterr(pd));
CleanExit(1);
}
gettimeofday(&endtime, &tz);
TIMERSUB(&endtime, &starttime, &difftime);
printf("Run time for packet processing was %lu.%lu seconds\n",
difftime.tv_sec, difftime.tv_usec);
CleanExit(0);
return NULL; /* avoid warnings */
}
이부분에서 pthread_create를 대신하는거 같은데 잘 이해가 안가내요.
이부분 때문에 막혀서 막막합니다. SNORT에 대해서 잘 아시는 고수 분들
도와 주세요 ..
제가 thread 에 대해서 알려고 하는것은 제가 snort 에서 udp써버 기능을
하는 부분을 추가시켜 따로 돌아 가게 해야되기 때문입니다. udp 써버에서
recv를 해야되기 때문에 블럭이 생길거 같아서 써버 자체를 thread로 돌려
서 해결할려고 하는데 잘 안되고 있습니다. 간단히 pthread_create함수를
snortmain() 함수에서 불러 들여 thread를 생성시켜서 수행시킬려고 하니
컴파일시 언디파인 됐다고 나와서 보니 컴파일시 -lpthread 를 안하고 했다
했다는것을 알고 Makefile부분에서 고쳐서 했는데 컴파일 에러는 안나는데
snort를 실행시키니 snort자체 기능을 실행을 안하더군요 .. 도대체 왜 이런
걸까요 도움 부탁 드립니다. 쓰레드를 쓰지 않고 해결할수 있는 방법이 있나요 ??
도와 주십시오 ...
무슨 작업을 하시는지 잘 감이 안옵니다만, snort 2.1에서는 thr
무슨 작업을 하시는지 잘 감이 안옵니다만, snort 2.1에서는 thread를
더이상 지원하지 않습니다. 하지만 코드를 추가해서 thread를 띄우거나
하는데에는 문제가 없을 것 같습니다.
댓글 달기