DAG: Consistent code style.

pull/950/head
Jason Ish 12 years ago committed by Victor Julien
parent c00ec5f4fc
commit 8ab962df7c

@ -38,7 +38,9 @@
TmEcode NoErfDagSupportExit(ThreadVars *, void *, void **);
void TmModuleReceiveErfDagRegister (void) {
void
TmModuleReceiveErfDagRegister(void)
{
tmm_modules[TMM_RECEIVEERFDAG].name = "ReceiveErfDag";
tmm_modules[TMM_RECEIVEERFDAG].ThreadInit = NoErfDagSupportExit;
tmm_modules[TMM_RECEIVEERFDAG].Func = NULL;
@ -49,7 +51,9 @@ void TmModuleReceiveErfDagRegister (void) {
tmm_modules[TMM_RECEIVEERFDAG].flags = TM_FLAG_RECEIVE_TM;
}
void TmModuleDecodeErfDagRegister (void) {
void
TmModuleDecodeErfDagRegister(void)
{
tmm_modules[TMM_DECODEERFDAG].name = "DecodeErfDag";
tmm_modules[TMM_DECODEERFDAG].ThreadInit = NoErfDagSupportExit;
tmm_modules[TMM_DECODEERFDAG].Func = NULL;
@ -60,7 +64,8 @@ void TmModuleDecodeErfDagRegister (void) {
tmm_modules[TMM_DECODEERFDAG].flags = TM_FLAG_DECODE_TM;
}
TmEcode NoErfDagSupportExit(ThreadVars *tv, void *initdata, void **data)
TmEcode
NoErfDagSupportExit(ThreadVars *tv, void *initdata, void **data)
{
SCLogError(SC_ERR_DAG_NOSUPPORT,
"Error creating thread %s: you do not have support for DAG cards "
@ -106,10 +111,10 @@ TmEcode ReceiveErfDagLoop(ThreadVars *, void *data, void *slot);
TmEcode ReceiveErfDagThreadInit(ThreadVars *, void *, void **);
void ReceiveErfDagThreadExitStats(ThreadVars *, void *);
TmEcode ReceiveErfDagThreadDeinit(ThreadVars *, void *);
TmEcode DecodeErfDagThreadInit(ThreadVars *, void *, void **);
TmEcode DecodeErfDagThreadDeinit(ThreadVars *tv, void *data);
TmEcode DecodeErfDag(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
TmEcode DecodeErfDag(ThreadVars *, Packet *, void *, PacketQueue *,
PacketQueue *);
void ReceiveErfDagCloseStream(int dagfd, int stream);
/**
@ -169,13 +174,15 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
int stream_count = 0;
if (initdata == NULL) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Error: No DAG interface provided.");
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Error: No DAG interface provided.");
SCReturnInt(TM_ECODE_FAILED);
}
ErfDagThreadVars *ewtn = SCMalloc(sizeof(ErfDagThreadVars));
if (unlikely(ewtn == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for ERF DAG thread vars.");
SCLogError(SC_ERR_MEM_ALLOC,
"Failed to allocate memory for ERF DAG thread vars.");
exit(EXIT_FAILURE);
}
@ -185,8 +192,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
* to open for this thread.
*/
if (dag_parse_name(initdata, ewtn->dagname, DAGNAME_BUFSIZE,
&ewtn->dagstream) < 0)
{
&ewtn->dagstream) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Failed to parse DAG interface: %s",
(char*)initdata);
@ -205,8 +211,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
SCLogInfo("Opening DAG: %s on stream: %d for processing",
ewtn->dagname, ewtn->dagstream);
if ((ewtn->dagfd = dag_open(ewtn->dagname)) < 0)
{
if ((ewtn->dagfd = dag_open(ewtn->dagname)) < 0) {
SCLogError(SC_ERR_ERF_DAG_OPEN_FAILED, "Failed to open DAG: %s",
ewtn->dagname);
SCFree(ewtn);
@ -216,8 +221,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
/* Check to make sure the card has enough available streams to
* support reading from the one specified.
*/
if ((stream_count = dag_rx_get_stream_count(ewtn->dagfd)) < 0)
{
if ((stream_count = dag_rx_get_stream_count(ewtn->dagfd)) < 0) {
SCLogError(SC_ERR_ERF_DAG_OPEN_FAILED,
"Failed to open stream: %d, DAG: %s, could not query stream count",
ewtn->dagstream, ewtn->dagname);
@ -228,8 +232,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
/* Check to make sure we have enough rx streams to open the stream
* the user is asking for.
*/
if (ewtn->dagstream > stream_count*2)
{
if (ewtn->dagstream > stream_count * 2) {
SCLogError(SC_ERR_ERF_DAG_OPEN_FAILED,
"Failed to open stream: %d, DAG: %s, insufficient streams: %d",
ewtn->dagstream, ewtn->dagname, stream_count);
@ -240,8 +243,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
/* If we are transmitting into a soft DAG card then set the stream
* to act in reverse mode.
*/
if (0 != (ewtn->dagstream & 0x01))
{
if (0 != (ewtn->dagstream & 0x01)) {
/* Setting reverse mode for using with soft dag from daemon side */
if (dag_set_mode(ewtn->dagfd, ewtn->dagstream, DAG_REVERSE_MODE)) {
SCLogError(SC_ERR_ERF_DAG_STREAM_OPEN_FAILED,
@ -252,8 +254,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
}
}
if (dag_attach_stream(ewtn->dagfd, ewtn->dagstream, 0, 0) < 0)
{
if (dag_attach_stream(ewtn->dagfd, ewtn->dagstream, 0, 0) < 0) {
SCLogError(SC_ERR_ERF_DAG_STREAM_OPEN_FAILED,
"Failed to open DAG stream: %d, DAG: %s",
ewtn->dagstream, ewtn->dagname);
@ -261,8 +262,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
SCReturnInt(TM_ECODE_FAILED);
}
if (dag_start_stream(ewtn->dagfd, ewtn->dagstream) < 0)
{
if (dag_start_stream(ewtn->dagfd, ewtn->dagstream) < 0) {
SCLogError(SC_ERR_ERF_DAG_STREAM_START_FAILED,
"Failed to start DAG stream: %d, DAG: %s",
ewtn->dagstream, ewtn->dagname);
@ -284,8 +284,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
/* 32kB minimum data to return -- we still restrict the number of
* pkts that are processed to a maximum of dag_max_read_packets.
*/
if (dag_set_stream_poll(ewtn->dagfd, ewtn->dagstream, 32*1024, &(ewtn->maxwait), &(ewtn->poll)) < 0)
{
if (dag_set_stream_poll(ewtn->dagfd, ewtn->dagstream, 32*1024, &(ewtn->maxwait), &(ewtn->poll)) < 0) {
SCLogError(SC_ERR_ERF_DAG_STREAM_SET_FAILED,
"Failed to set poll parameters for stream: %d, DAG: %s",
ewtn->dagstream, ewtn->dagname);
@ -317,7 +316,8 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
* \retval TM_ECODE_OK on success
* \retval TM_ECODE_FAILED on failure
*/
TmEcode ReceiveErfDagLoop(ThreadVars *tv, void *data, void *slot)
TmEcode
ReceiveErfDagLoop(ThreadVars *tv, void *data, void *slot)
{
SCEnter();
@ -330,8 +330,7 @@ TmEcode ReceiveErfDagLoop(ThreadVars *tv, void *data, void *slot)
dtv->slot = s->slot_next;
while (1)
{
while (1) {
if (suricata_ctl_flags & (SURICATA_STOP | SURICATA_KILL)) {
SCReturnInt(TM_ECODE_OK);
}
@ -385,8 +384,8 @@ TmEcode ReceiveErfDagLoop(ThreadVars *tv, void *data, void *slot)
* This function takes a pointer to buffer read from the DAG interface
* and processes it individual records.
*/
static inline TmEcode ProcessErfDagRecords(ErfDagThreadVars *ewtn, uint8_t *top,
uint32_t *pkts_read)
static inline TmEcode
ProcessErfDagRecords(ErfDagThreadVars *ewtn, uint8_t *top, uint32_t *pkts_read)
{
SCEnter();
@ -465,7 +464,8 @@ static inline TmEcode ProcessErfDagRecords(ErfDagThreadVars *ewtn, uint8_t *top,
* \param prec pointer to a DAG record.
* \param
*/
static inline TmEcode ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec)
static inline TmEcode
ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec)
{
SCEnter();
@ -572,7 +572,8 @@ ReceiveErfDagThreadExitStats(ThreadVars *tv, void *data)
* \param tv pointer to ThreadVars
* \param data pointer that gets cast into PcapThreadVars for ptv
*/
TmEcode ReceiveErfDagThreadDeinit(ThreadVars *tv, void *data)
TmEcode
ReceiveErfDagThreadDeinit(ThreadVars *tv, void *data)
{
SCEnter();
@ -583,7 +584,8 @@ TmEcode ReceiveErfDagThreadDeinit(ThreadVars *tv, void *data)
SCReturnInt(TM_ECODE_OK);
}
void ReceiveErfDagCloseStream(int dagfd, int stream)
void
ReceiveErfDagCloseStream(int dagfd, int stream)
{
dag_stop_stream(dagfd, stream);
dag_detach_stream(dagfd, stream);
@ -603,7 +605,8 @@ void ReceiveErfDagCloseStream(int dagfd, int stream)
* \param data pointer that gets cast into PcapThreadVars for ptv
* \param pq pointer to the current PacketQueue
*/
TmEcode DecodeErfDag(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq,
TmEcode
DecodeErfDag(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq,
PacketQueue *postpq)
{
SCEnter();
@ -625,8 +628,10 @@ TmEcode DecodeErfDag(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq,
(GET_PKT_LEN(p) * 8)/1000000.0);
#endif
SCPerfCounterAddUI64(dtv->counter_avg_pkt_size, tv->sc_perf_pca, GET_PKT_LEN(p));
SCPerfCounterSetUI64(dtv->counter_max_pkt_size, tv->sc_perf_pca, GET_PKT_LEN(p));
SCPerfCounterAddUI64(dtv->counter_avg_pkt_size, tv->sc_perf_pca,
GET_PKT_LEN(p));
SCPerfCounterSetUI64(dtv->counter_max_pkt_size, tv->sc_perf_pca,
GET_PKT_LEN(p));
/* call the decoder */
switch(p->datalink) {
@ -635,7 +640,8 @@ TmEcode DecodeErfDag(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq,
break;
default:
SCLogError(SC_ERR_DATALINK_UNIMPLEMENTED,
"Error: datalink type %" PRId32 " not yet supported in module DecodeErfDag",
"Error: datalink type %" PRId32
" not yet supported in module DecodeErfDag",
p->datalink);
break;
}
@ -645,7 +651,8 @@ TmEcode DecodeErfDag(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq,
SCReturnInt(TM_ECODE_OK);
}
TmEcode DecodeErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
TmEcode
DecodeErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
{
SCEnter();
DecodeThreadVars *dtv = NULL;
@ -662,7 +669,8 @@ TmEcode DecodeErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
SCReturnInt(TM_ECODE_OK);
}
TmEcode DecodeErfDagThreadDeinit(ThreadVars *tv, void *data)
TmEcode
DecodeErfDagThreadDeinit(ThreadVars *tv, void *data)
{
if (data != NULL)
DecodeThreadVarsFree(data);

Loading…
Cancel
Save