Example #1
0
void UdpSessionCleanup(void *ssn)
{
    SessionControlBlock *scb = ( SessionControlBlock * ) ssn;

    UdpSession *udpssn = NULL;

    if (scb->ha_state.session_flags & SSNFLAG_PRUNED)
    {
        CloseStreamSession(&sfBase, SESSION_CLOSED_PRUNED);
    }
    else if (scb->ha_state.session_flags & SSNFLAG_TIMEDOUT)
    {
        CloseStreamSession(&sfBase, SESSION_CLOSED_TIMEDOUT);
    }
    else
    {
        CloseStreamSession(&sfBase, SESSION_CLOSED_NORMALLY);
    }

    if (scb->proto_specific_data)
        udpssn = (UdpSession *)scb->proto_specific_data->data;

    if (!udpssn)
    {
        /* Huh? */
        return;
    }
 
    /* Cleanup the proto specific data */
    session_api->free_protocol_session_pool( SESSION_PROTO_UDP, scb );
    scb->proto_specific_data = NULL;
    scb->session_state = STREAM_STATE_NONE;
    scb->ha_state.session_flags = SSNFLAG_NONE;
    scb->expire_time = 0;
    scb->ha_state.ignore_direction = 0;

    StreamResetFlowBits(scb);
    session_api->free_application_data(scb);

    s5stats.udp_sessions_released++;

    RemoveUDPSession(&sfBase);
}
void UdpSessionCleanup(Stream5LWSession *lwssn)
{
    UdpSession *udpssn = NULL;

    if (lwssn->session_flags & SSNFLAG_PRUNED)
    {
        CloseStreamSession(&sfBase, SESSION_CLOSED_PRUNED);
    }
    else if (lwssn->session_flags & SSNFLAG_TIMEDOUT)
    {
        CloseStreamSession(&sfBase, SESSION_CLOSED_TIMEDOUT);
    }
    else
    {
        CloseStreamSession(&sfBase, SESSION_CLOSED_NORMALLY);
    }

    if (lwssn->proto_specific_data)
        udpssn = (UdpSession *)lwssn->proto_specific_data->data;

    if (!udpssn)
    {
        /* Huh? */
        return;
    }

    /* Cleanup the proto specific data */
    mempool_free(&udp_session_mempool, lwssn->proto_specific_data);
    lwssn->proto_specific_data = NULL;
    lwssn->session_state = STREAM5_STATE_NONE;
    lwssn->session_flags = SSNFLAG_NONE;
    lwssn->expire_time = 0;
    lwssn->ignore_direction = 0;

    Stream5ResetFlowBits(lwssn);
    FreeLWApplicationData(lwssn);

    s5stats.udp_sessions_released++;

    RemoveUDPSession(&sfBase);
}