Snort 에서 thread 사용에 대해 ???????

madbattle의 이미지

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자체 기능을 실행을 안하더군요 .. 도대체 왜 이런

걸까요 도움 부탁 드립니다. 쓰레드를 쓰지 않고 해결할수 있는 방법이 있나요 ??

도와 주십시오 ...

errai의 이미지

무슨 작업을 하시는지 잘 감이 안옵니다만, snort 2.1에서는 thread를
더이상 지원하지 않습니다. 하지만 코드를 추가해서 thread를 띄우거나
하는데에는 문제가 없을 것 같습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.