axis2_status_t AXIS2_CALL tcpmon_session_free()

in tools/tcpmon/src/session.c [66:198]


axis2_status_t AXIS2_CALL tcpmon_session_free(
    tcpmon_session_t * session,
    const axutil_env_t * env);

axis2_status_t AXIS2_CALL tcpmon_session_set_listen_port(
    tcpmon_session_t * session,
    const axutil_env_t * env,
    int listen_port);

int AXIS2_CALL tcpmon_session_get_listen_port(
    tcpmon_session_t * session,
    const axutil_env_t * env);

axis2_status_t AXIS2_CALL tcpmon_session_set_target_port(
    tcpmon_session_t * session,
    const axutil_env_t * env,
    int target_port);

int AXIS2_CALL tcpmon_session_get_target_port(
    tcpmon_session_t * session,
    const axutil_env_t * env);

axis2_status_t AXIS2_CALL tcpmon_session_set_target_host(
    tcpmon_session_t * session,
    const axutil_env_t * env,
    axis2_char_t * target_host);

axis2_char_t *AXIS2_CALL tcpmon_session_get_target_host(
    tcpmon_session_t * session,
    const axutil_env_t * env);

axis2_status_t AXIS2_CALL tcpmon_session_start(
    tcpmon_session_t * session,
    const axutil_env_t * env);

axis2_status_t AXIS2_CALL tcpmon_session_stop(
    tcpmon_session_t * session,
    const axutil_env_t * env);

axis2_status_t AXIS2_CALL tcpmon_session_on_new_entry(
    tcpmon_session_t * session,
    const axutil_env_t * env,
    TCPMON_SESSION_NEW_ENTRY_FUNCT on_new_entry_funct);

axis2_status_t AXIS2_CALL tcpmon_session_on_trans_fault(
    tcpmon_session_t * session,
    const axutil_env_t * env,
    TCPMON_SESSION_TRANS_ERROR_FUNCT on_trans_fault_funct);

int AXIS2_CALL tcpmon_session_get_test_bit(
    tcpmon_session_t * session,
    const axutil_env_t * env);

int AXIS2_CALL tcpmon_session_set_test_bit(
    tcpmon_session_t * session,
    const axutil_env_t * env,
    int test_bit);

int AXIS2_CALL tcpmon_session_get_format_bit(
    tcpmon_session_t * session,
    const axutil_env_t * env);

int AXIS2_CALL tcpmon_session_set_format_bit(
    tcpmon_session_t * session,
    const axutil_env_t * env,
    int format_bit);

/** internal implementations */

static void *AXIS2_THREAD_FUNC server_funct(
    axutil_thread_t * thd,
    void *data);

/************************** End of function prototypes ************************/

tcpmon_session_t *AXIS2_CALL
tcpmon_session_create(
    const axutil_env_t * env)
{
    tcpmon_session_impl_t *session_impl = NULL;

    AXIS2_ENV_CHECK(env, NULL);

    session_impl = (tcpmon_session_impl_t *) AXIS2_MALLOC(env->
                                                          allocator,
                                                          sizeof
                                                          (tcpmon_session_impl_t));

    if (!session_impl)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        return NULL;
    }

    session_impl->listen_port = -1;
    session_impl->target_port = -1;
    session_impl->test_bit = -1;
    session_impl->format_bit = 0;
    session_impl->target_host = NULL;

    session_impl->on_new_entry_funct = NULL;
    session_impl->on_trans_fault_funct = NULL;
    session_impl->entries =
        axutil_array_list_create(env, AXIS2_ARRAY_LIST_DEFAULT_CAPACITY);

    session_impl->session.ops =
        AXIS2_MALLOC(env->allocator, sizeof(tcpmon_session_ops_t));
    if (!session_impl->session.ops)
    {
        tcpmon_session_free(&(session_impl->session), env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        return NULL;
    }

    session_impl->is_running = AXIS2_FALSE;
    session_impl->session.ops->free = tcpmon_session_free;
    session_impl->session.ops->set_test_bit = tcpmon_session_set_test_bit;
    session_impl->session.ops->get_test_bit = tcpmon_session_get_test_bit;
    session_impl->session.ops->get_format_bit = tcpmon_session_get_format_bit;
    session_impl->session.ops->set_format_bit = tcpmon_session_set_format_bit;
    session_impl->session.ops->set_listen_port = tcpmon_session_set_listen_port;
    session_impl->session.ops->get_listen_port = tcpmon_session_get_listen_port;
    session_impl->session.ops->set_target_port = tcpmon_session_set_target_port;
    session_impl->session.ops->get_target_port = tcpmon_session_get_target_port;
    session_impl->session.ops->set_target_host = tcpmon_session_set_target_host;
    session_impl->session.ops->get_target_host = tcpmon_session_get_target_host;
    session_impl->session.ops->start = tcpmon_session_start;
    session_impl->session.ops->stop = tcpmon_session_stop;
    session_impl->session.ops->on_new_entry = tcpmon_session_on_new_entry;
    session_impl->session.ops->on_trans_fault = tcpmon_session_on_trans_fault;

    return &(session_impl->session);
}