remotes/origin/master-1.0.x
Gurvinder Singh 16 years ago committed by Victor Julien
parent 4f3a04a410
commit 5293681860

@ -1,6 +1,7 @@
# not a GNU package. You can remove this line, if
# have all needed files, that a GNU package needs
AUTOMAKE_OPTIONS = foreign 1.4
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = ChangeLog COPYING LICENSE suricata.yaml \
doc/AUTHORS doc/GITGUIDE doc/INSTALL doc/NEWS \
doc/README doc/TODO

@ -212,10 +212,12 @@ TmEcode NFQInitThread(NFQThreadVars *nfq_t, uint16_t queue_num, uint32_t queue_m
* run. Ignoring the error seems to have no bad effects. */
SCLogDebug("unbinding existing nf_queue handler for AF_INET (if any)");
if (nfq_unbind_pf(nfq_t->h, AF_INET) < 0) {
SCLogWarning(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET failed");
SCLogError(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET failed");
exit(EXIT_FAILURE);
}
if (nfq_unbind_pf(nfq_t->h, AF_INET6) < 0) {
SCLogWarning(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET6 failed");
SCLogError(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET6 failed");
exit(EXIT_FAILURE);
}
nfq_g.unbind = 1;
@ -223,11 +225,11 @@ TmEcode NFQInitThread(NFQThreadVars *nfq_t, uint16_t queue_num, uint32_t queue_m
if (nfq_bind_pf(nfq_t->h, AF_INET) < 0) {
SCLogError(SC_ERR_NFQ_BIND, "nfq_bind_pf() for AF_INET failed");
return TM_ECODE_FAILED;
exit(EXIT_FAILURE);
}
if (nfq_bind_pf(nfq_t->h, AF_INET6) < 0) {
SCLogError(SC_ERR_NFQ_BIND, "nfq_bind_pf() for AF_INET6 failed");
return TM_ECODE_FAILED;
exit(EXIT_FAILURE);
}
}

@ -143,8 +143,9 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) {
char errbuf[PCAP_ERRBUF_SIZE] = "";
pcap_g.pcap_handle = pcap_open_offline((char *)initdata, errbuf);
if (pcap_g.pcap_handle == NULL) {
printf("error %s\n", errbuf);
return TM_ECODE_FAILED;
SCLogError(SC_ERR_FOPEN, "%s\n", errbuf);
free(ptv);
exit(EXIT_FAILURE);
}
if (ConfGet("bpf-filter", &tmpbpfstring) != 1) {
@ -154,11 +155,13 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) {
if(pcap_compile(pcap_g.pcap_handle,&pcap_g.filter,tmpbpfstring,1,0) < 0) {
SCLogError(SC_ERR_BPF,"bpf compilation error %s",pcap_geterr(pcap_g.pcap_handle));
free(ptv);
return TM_ECODE_FAILED;
}
if(pcap_setfilter(pcap_g.pcap_handle,&pcap_g.filter) < 0) {
SCLogError(SC_ERR_BPF,"could not set bpf filter %s",pcap_geterr(pcap_g.pcap_handle));
free(ptv);
return TM_ECODE_FAILED;
}
}
@ -181,7 +184,8 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) {
break;
default:
printf("Error: datalink type %" PRId32 " not (yet) supported in module PcapFile.\n", pcap_g.datalink);
SCLogError(SC_ERR_UNIMPLEMENTED, "datalink type %" PRId32 " not "
"(yet) supported in module PcapFile.\n", pcap_g.datalink);
free(ptv);
return TM_ECODE_FAILED;
}

@ -168,7 +168,7 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
char *tmpbpfstring;
if (initdata == NULL) {
printf("ReceivePcapThreadInit error: initdata == NULL\n");
SCLogError(SC_ERR_PCAP_RECV_INIT, "initdata == NULL");
return TM_ECODE_FAILED;
}
@ -186,7 +186,8 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
char errbuf[PCAP_ERRBUF_SIZE];
ptv->pcap_handle = pcap_create((char *)initdata, errbuf);
if (ptv->pcap_handle == NULL) {
printf("error %s\n", pcap_geterr(ptv->pcap_handle));
SCLogError(SC_ERR_PCAP_RECV_INIT, " %s", pcap_geterr(ptv->pcap_handle));
free(ptv);
return TM_ECODE_FAILED;
}
@ -194,21 +195,24 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
int pcap_set_snaplen_r = pcap_set_snaplen(ptv->pcap_handle,LIBPCAP_SNAPLEN);
//printf("ReceivePcapThreadInit: pcap_set_snaplen(%p) returned %" PRId32 "\n", ptv->pcap_handle, pcap_set_snaplen_r);
if (pcap_set_snaplen_r != 0) {
printf("ReceivePcapThreadInit: error is %s\n", pcap_geterr(ptv->pcap_handle));
SCLogError(SC_ERR_PCAP_RECV_INIT, " %s", pcap_geterr(ptv->pcap_handle));
free(ptv);
return TM_ECODE_FAILED;
}
int pcap_set_promisc_r = pcap_set_promisc(ptv->pcap_handle,LIBPCAP_PROMISC);
//printf("ReceivePcapThreadInit: pcap_set_promisc(%p) returned %" PRId32 "\n", ptv->pcap_handle, pcap_set_promisc_r);
if (pcap_set_promisc_r != 0) {
printf("ReceivePcapThreadInit: error is %s\n", pcap_geterr(ptv->pcap_handle));
SCLogError(SC_ERR_PCAP_RECV_INIT, "%s", pcap_geterr(ptv->pcap_handle));
free(ptv);
return TM_ECODE_FAILED;
}
int pcap_set_timeout_r = pcap_set_timeout(ptv->pcap_handle,LIBPCAP_COPYWAIT);
//printf("ReceivePcapThreadInit: pcap_set_timeout(%p) returned %" PRId32 "\n", ptv->pcap_handle, pcap_set_timeout_r);
if (pcap_set_timeout_r != 0) {
printf("ReceivePcapThreadInit: error is %s\n", pcap_geterr(ptv->pcap_handle));
SCLogError(SC_ERR_PCAP_RECV_INIT, " %s", pcap_geterr(ptv->pcap_handle));
free(ptv);
return TM_ECODE_FAILED;
}
@ -216,8 +220,9 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
int pcap_activate_r = pcap_activate(ptv->pcap_handle);
//printf("ReceivePcapThreadInit: pcap_activate(%p) returned %" PRId32 "\n", ptv->pcap_handle, pcap_activate_r);
if (pcap_activate_r != 0) {
printf("ReceivePcapThreadInit: error is %s\n", pcap_geterr(ptv->pcap_handle));
return TM_ECODE_FAILED;
SCLogError(SC_ERR_PCAP_RECV_INIT, " %s", pcap_geterr(ptv->pcap_handle));
free(ptv);
exit(EXIT_FAILURE);
}
/* set bpf filter if we have one */
@ -228,11 +233,13 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
if(pcap_compile(ptv->pcap_handle,&ptv->filter,tmpbpfstring,1,0) < 0) {
SCLogError(SC_ERR_BPF,"bpf compilation error %s",pcap_geterr(ptv->pcap_handle));
free(ptv);
return TM_ECODE_FAILED;
}
if(pcap_setfilter(ptv->pcap_handle,&ptv->filter) < 0) {
SCLogError(SC_ERR_BPF,"could not set bpf filter %s",pcap_geterr(ptv->pcap_handle));
free(ptv);
return TM_ECODE_FAILED;
}
}

@ -95,6 +95,9 @@ const char * SCErrorToString(SCError err)
CASE_CODE (SC_ERR_INVALID_VALUE);
CASE_CODE (SC_ERR_UNKNOWN_REGEX_MOD);
CASE_CODE (SC_ERR_INVALID_OPERATOR);
CASE_CODE (SC_ERR_PCAP_RECV_INIT);
CASE_CODE (SC_ERR_NFQ_UNBIND);
CASE_CODE (SC_ERR_NFQ_BIND);
default:
return "UNKNOWN_ERROR";
}

@ -114,6 +114,7 @@ typedef enum {
SC_ERR_INVALID_VALUE,
SC_ERR_UNKNOWN_REGEX_MOD,
SC_ERR_INVALID_OPERATOR,
SC_ERR_PCAP_RECV_INIT,
} SCError;
const char *SCErrorToString(SCError);

Loading…
Cancel
Save