Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Improve handling of Sguil agent registration timeouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjulien authored and firnsy committed May 17, 2011
1 parent 124d1d6 commit c78a916
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/output-plugins/spo_sguil.c
Expand Up @@ -417,6 +417,8 @@ void Sguil(Packet *p, void *event, uint32_t event_type, void *arg)
#endif
}

static unsigned int sguil_agent_setup_timeouts = 0;

int SguilRTEventMsg(SpoSguilData *data, char *msg)
{

Expand Down Expand Up @@ -445,19 +447,28 @@ int SguilRTEventMsg(SpoSguilData *data, char *msg)
/* Parse the response */
toks = mSplit(tmpRecvMsg, " ", 2, &num_toks, 0);

int event_id = atoi(toks[1]);
if (event_id < 0) {
FatalError("sguil: Malformed response, expected \"Confirm %u\", got: %s\n",
data->event_id, tmpRecvMsg);
/* if the agent registration timed out once or several times we can
* receive unexpected SidCidResponse messages. */
if (sguil_agent_setup_timeouts > 0 && strcasecmp("SidCidResponse", toks[0]) == 0)
{
sguil_agent_setup_timeouts--;
}

if(strcasecmp("Confirm", toks[0]) != 0 || (uint)event_id != data->event_id )
else
{
FatalError("sguil: Expected Confirm %u and got: %s\n", data->event_id, tmpRecvMsg);
int event_id = atoi(toks[1]);
if (event_id < 0)
{
FatalError("sguil: Malformed response, expected \"Confirm %u\", got: %s\n",
data->event_id, tmpRecvMsg);
}

if(strcasecmp("Confirm", toks[0]) != 0 || (uint)event_id != data->event_id )
{
FatalError("sguil: Expected Confirm %u and got: %s\n", data->event_id, tmpRecvMsg);
}
}

mSplitFree(&toks, num_toks);

}

return 0;
Expand Down Expand Up @@ -901,6 +912,8 @@ int SguilSensorAgentInit(SpoSguilData *ssd_data)

if ( SguilRecvAgentMsg(ssd_data, tmpRecvMsg) == 1 )
{
sguil_agent_setup_timeouts++;

/* timeout, resend */
SguilSensorAgentInit(ssd_data);
}
Expand Down

0 comments on commit c78a916

Please sign in to comment.