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

@ -276,7 +276,6 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) {
int rc;
u_int32_t version = 0;
char *tmpclusterid;
char *tmpctype;
PfringIfaceConfig *pfconf = (PfringIfaceConfig *) initdata;
@ -313,7 +312,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) {
ptv->cluster_id = pfconf->cluster_id;
#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);
#else
rc = pfring_set_cluster(ptv->pd, ptv->cluster_id);
@ -383,10 +382,6 @@ TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data) {
PfringThreadVars *ptv = (PfringThreadVars *)data;
if (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_close(ptv->pd);
return TM_ECODE_OK;

@ -53,4 +53,8 @@ void TmModuleDecodePfringRegister (void);
int PfringConfGetThreads(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__ */

Loading…
Cancel
Save