pfring: fix stupid enum usage.

pfring code is not using standard notation for the cluster_type enum
and this leads to a horrific code in pfring acquisition code.
remotes/origin/master-1.1.x
Eric Leblond 14 years ago committed by Victor Julien
parent a6a0d4eae6
commit 866d681ff2

@ -106,7 +106,7 @@ void *OldParsePfringConfig(const char *iface)
char *tmpclusterid; char *tmpclusterid;
#ifdef HAVE_PFRING_CLUSTER_TYPE #ifdef HAVE_PFRING_CLUSTER_TYPE
char *tmpctype = NULL; char *tmpctype = NULL;
char * default_ctype = SCStrdup("cluster_round_robin"); cluster_type default_ctype = CLUSTER_ROUND_ROBIN;
#endif #endif
if (iface == NULL) { if (iface == NULL) {
@ -120,7 +120,7 @@ void *OldParsePfringConfig(const char *iface)
pfconf->threads = 1; pfconf->threads = 1;
pfconf->cluster_id = 1; pfconf->cluster_id = 1;
#ifdef HAVE_PFRING_CLUSTER_TYPE #ifdef HAVE_PFRING_CLUSTER_TYPE
pfconf->ctype = (cluster_type)default_ctype; pfconf->ctype = default_ctype;
#endif #endif
pfconf->DerefFunc = PfringDerefConfig; pfconf->DerefFunc = PfringDerefConfig;
SC_ATOMIC_INIT(pfconf->ref); SC_ATOMIC_INIT(pfconf->ref);
@ -190,8 +190,7 @@ void *ParsePfringConfig(const char *iface)
char *tmpclusterid; char *tmpclusterid;
#ifdef HAVE_PFRING_CLUSTER_TYPE #ifdef HAVE_PFRING_CLUSTER_TYPE
char *tmpctype = NULL; char *tmpctype = NULL;
/* TODO free me */ cluster_type default_ctype = CLUSTER_ROUND_ROBIN;
char * default_ctype = SCStrdup("cluster_round_robin");
int getctype = 0; int getctype = 0;
#endif #endif
@ -276,11 +275,11 @@ void *ParsePfringConfig(const char *iface)
if (strcmp(tmpctype, "cluster_round_robin") == 0) { if (strcmp(tmpctype, "cluster_round_robin") == 0) {
SCLogInfo("Using round-robin cluster mode for PF_RING (iface %s)", SCLogInfo("Using round-robin cluster mode for PF_RING (iface %s)",
pfconf->iface); pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype; pfconf->ctype = CLUSTER_ROUND_ROBIN;
} else if (strcmp(tmpctype, "cluster_flow") == 0) { } else if (strcmp(tmpctype, "cluster_flow") == 0) {
SCLogInfo("Using flow cluster mode for PF_RING (iface %s)", SCLogInfo("Using flow cluster mode for PF_RING (iface %s)",
pfconf->iface); pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype; pfconf->ctype = CLUSTER_FLOW;
} else { } else {
SCLogError(SC_ERR_INVALID_CLUSTER_TYPE, SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,
"invalid cluster-type %s", "invalid cluster-type %s",

@ -276,7 +276,6 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) {
int rc; int rc;
u_int32_t version = 0; u_int32_t version = 0;
char *tmpclusterid; char *tmpclusterid;
char *tmpctype;
PfringIfaceConfig *pfconf = (PfringIfaceConfig *) initdata; PfringIfaceConfig *pfconf = (PfringIfaceConfig *) initdata;
@ -313,7 +312,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) {
ptv->cluster_id = pfconf->cluster_id; ptv->cluster_id = pfconf->cluster_id;
#ifdef HAVE_PFRING_CLUSTER_TYPE #ifdef HAVE_PFRING_CLUSTER_TYPE
ptv->ctype = (cluster_type)SCStrdup((char *)pfconf->ctype); ptv->ctype = pfconf->ctype;
rc = pfring_set_cluster(ptv->pd, ptv->cluster_id, ptv->ctype); rc = pfring_set_cluster(ptv->pd, ptv->cluster_id, ptv->ctype);
#else #else
rc = pfring_set_cluster(ptv->pd, ptv->cluster_id); rc = pfring_set_cluster(ptv->pd, ptv->cluster_id);
@ -383,10 +382,6 @@ TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data) {
PfringThreadVars *ptv = (PfringThreadVars *)data; PfringThreadVars *ptv = (PfringThreadVars *)data;
if (ptv->interface) if (ptv->interface)
SCFree(ptv->interface); SCFree(ptv->interface);
#ifdef HAVE_PFRING_CLUSTER_TYPE
if (ptv->ctype)
SCFree((char *)ptv->ctype);
#endif
pfring_remove_from_cluster(ptv->pd); pfring_remove_from_cluster(ptv->pd);
pfring_close(ptv->pd); pfring_close(ptv->pd);
return TM_ECODE_OK; return TM_ECODE_OK;

@ -53,4 +53,8 @@ void TmModuleDecodePfringRegister (void);
int PfringConfGetThreads(void); int PfringConfGetThreads(void);
void PfringLoadConfig(void); void PfringLoadConfig(void);
/* We don't have to use an enum that sucks in our code */
#define CLUSTER_FLOW 0
#define CLUSTER_ROUND_ROBIN 1
#endif /* __SOURCE_PFRING_H__ */ #endif /* __SOURCE_PFRING_H__ */

Loading…
Cancel
Save