} else if (server_ok == 2) {
p1 = FlowForceReassemblyPseudoPacketGet(1, f, ssn, 1);
if (p1 == NULL) {
- TmqhOutputPacketpool(NULL, p1);
return 1;
}
} else {
{
SCMutexLock(&plog_lock);
const char *filename = NULL;
+
if (conf != NULL) { /* To faciliate unit tests. */
filename = ConfNodeLookupChildValue(conf, "filename");
}
+
if (filename == NULL)
filename = DEFAULT_LOG_FILENAME;
if ((pl->prefix = SCStrdup(filename)) == NULL) {
-
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for directory name");
- return NULL;
+ SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for directory name");
+ SCMutexUnlock(&plog_lock);
+ return NULL;
}
pl->size_limit = DEFAULT_LIMIT;
SCEnter();
StreamTcpSackRecord *rec = stream->sack_head;
- StreamTcpSackRecord *prev = NULL;
while (rec != NULL) {
if (SEQ_LT(rec->re, stream->last_ack)) {
SCLogDebug("removing le %u re %u", rec->le, rec->re);
- // fully before last_ack, remove
- if (prev != NULL) {
- if (rec == stream->sack_tail) {
- stream->sack_tail = prev;
- prev->next = NULL;
- SCFree(rec);
- break;
- } else {
- prev->next = rec->next;
- SCFree(rec);
- rec = prev->next;
- continue;
- }
+ if (rec->next != NULL) {
+ stream->sack_head = rec->next;
+ SCFree(rec);
+ rec = stream->sack_head;
+ continue;
} else {
- if (rec->next != NULL) {
- stream->sack_head = rec->next;
- SCFree(rec);
- rec = stream->sack_head;
- continue;
- } else {
- stream->sack_head = NULL;
- stream->sack_tail = NULL;
- SCFree(rec);
- break;
- }
+ stream->sack_head = NULL;
+ stream->sack_tail = NULL;
+ SCFree(rec);
+ break;
}
} else if (SEQ_LT(rec->le, stream->last_ack)) {
SCLogDebug("adjusting record to le %u re %u", rec->le, rec->re);
* \param tv Thread Variable containig input/output queue, cpu affinity
* \param p Packet which has to be handled in this TCP state.
* \param stt Strean Thread module registered to handle the stream handling
+ *
+ * \retval 0 ok
+ * \retval -1 error
*/
static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p,
StreamTcpThread *stt, TcpSession *ssn, PacketQueue *pq)
SCLogDebug("default case");
break;
}
+
return 0;
}
* inject a fake packet into the system, forcing reassembly of the
* opposing direction.
* There should be only one, but to be sure we do a while loop. */
- while (stt->pseudo_queue.len > 0) {
- SCLogDebug("processing pseudo packet / stream end");
- Packet *np = PacketDequeue(&stt->pseudo_queue);
- if (np != NULL) {
- /* process the opposing direction of the original packet */
- if (PKT_IS_TOSERVER(np)) {
- SCLogDebug("pseudo packet is to server");
- StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
- &ssn->client, np, NULL);
- } else {
- SCLogDebug("pseudo packet is to client");
- StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
- &ssn->server, np, NULL);
+ if (ssn != NULL) {
+ while (stt->pseudo_queue.len > 0) {
+ SCLogDebug("processing pseudo packet / stream end");
+ Packet *np = PacketDequeue(&stt->pseudo_queue);
+ if (np != NULL) {
+ /* process the opposing direction of the original packet */
+ if (PKT_IS_TOSERVER(np)) {
+ SCLogDebug("pseudo packet is to server");
+ StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
+ &ssn->client, np, NULL);
+ } else {
+ SCLogDebug("pseudo packet is to client");
+ StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
+ &ssn->server, np, NULL);
+ }
+
+ /* enqueue this packet so we inspect it in detect etc */
+ PacketEnqueue(pq, np);
}
+ SCLogDebug("processing pseudo packet / stream end done");
+ }
- /* enqueue this packet so we inspect it in detect etc */
- PacketEnqueue(pq, np);
+ /* Process stream smsgs we may have in queue */
+ if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx) < 0) {
+ goto error;
}
- SCLogDebug("processing pseudo packet / stream end done");
- }
- /* Process stream smsgs we may have in queue */
- if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx) < 0) {
- goto error;
- }
+ /* recalc the csum on the packet if it was modified */
+ if (p->flags & PKT_STREAM_MODIFIED) {
+ ReCalculateChecksum(p);
+ }
- /* recalc the csum on the packet if it was modified */
- if (p->flags & PKT_STREAM_MODIFIED) {
- ReCalculateChecksum(p);
- }
+ /* check for conditions that may make us not want to log this packet */
- /* check for conditions that may make us not want to log this packet */
- if (ssn != NULL) {
/* streams that hit depth */
if ((ssn->client.flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED ||
ssn->server.flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED))
{
ThreadVars *tv = (ThreadVars *)td;
TmSlot *s = (TmSlot *)tv->tm_slots;
- Packet *p = NULL;
char run = 1;
TmEcode r = TM_ECODE_OK;
TmThreadTestThreadUnPaused(tv);
PACKET_PROFILING_TMM_START(p, s->tm_id);
- r = s->SlotFunc(tv, p, s->slot_data, &s->slot_pre_pq, &s->slot_post_pq);
+ r = s->SlotFunc(tv, NULL, s->slot_data, &s->slot_pre_pq, &s->slot_post_pq);
PACKET_PROFILING_TMM_END(p, s->tm_id);
/* handle error */
TmqhReleasePacketsToPacketPool(&s->slot_post_pq);
SCMutexUnlock(&s->slot_post_pq.mutex_q);
- if (p != NULL)
- TmqhOutputPacketpool(tv, p);
TmThreadsSetFlag(tv, THV_FAILED);
break;
}
tv->tmqh_out(tv, extra_p);
}
- tv->tmqh_out(tv, p);
- if (p != NULL)
- tv->tmqh_out(tv, p);
-
/* handle post queue */
if (s->slot_post_pq.top != NULL) {
SCMutexLock(&s->slot_post_pq.mutex_q);
SCLogError(SC_ERR_FATAL, "TmSlot or ThreadVars badly setup: s=%p,"
" PktAcqLoop=%p, tmqh_in=%p,"
" tmqh_out=%p",
- s, s->PktAcqLoop, tv->tmqh_in, tv->tmqh_out);
+ s, s ? s->PktAcqLoop : NULL, tv->tmqh_in, tv->tmqh_out);
EngineKill();
TmThreadsSetFlag(tv, THV_CLOSED);
}
memset(tname, 0, sizeof(tname));
snprintf(tname, sizeof(tname), "Recv-Q%s", cur_queue);
- if (tname == NULL) {
- printf("ERROR: Unable to build thread name\n");
- exit(EXIT_FAILURE);
- }
char *thread_name = SCStrdup(tname);
ThreadVars *tv_receivenfq =
}
memset(tname, 0, sizeof(tname));
snprintf(tname, sizeof(tname), "Recv-Q%s", cur_queue);
- if (tname == NULL) {
- printf("ERROR: Unable to build thread name\n");
- exit(EXIT_FAILURE);
- }
char *thread_name = SCStrdup(tname);