in src/util/msg_init.c [264:460]
static axis2_bool_t validate_msg(
const axutil_env_t *env,
sandesha2_msg_ctx_t *rm_msg_ctx)
{
axis2_conf_ctx_t *conf_ctx = NULL;
axis2_msg_ctx_t *temp_msg_ctx = NULL;
axis2_char_t *seq_id = NULL;
axis2_char_t *rm_ns = NULL;
axis2_char_t *prop_key = NULL;
sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
sandesha2_create_seq_t *create_seq = NULL;
sandesha2_create_seq_res_t *create_seq_res = NULL;
sandesha2_terminate_seq_t *terminate_seq = NULL;
sandesha2_terminate_seq_res_t *terminate_seq_res = NULL;
sandesha2_seq_ack_t *seq_ack = NULL;
sandesha2_seq_t *seq = NULL;
sandesha2_ack_requested_t *ack_request = NULL;
sandesha2_close_seq_t *close_seq = NULL;
sandesha2_close_seq_res_t *close_seq_res = NULL;
sandesha2_make_connection_t *make_conn = NULL;
int temp_flow = -1;
axis2_char_t *dbname = NULL;
AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:validate_msg");
temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
conf_ctx = axis2_msg_ctx_get_conf_ctx(temp_msg_ctx, env);
dbname = sandesha2_util_get_dbname(env, conf_ctx);
seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
create_seq = sandesha2_msg_ctx_get_create_seq(rm_msg_ctx, env);
create_seq_res = sandesha2_msg_ctx_get_create_seq_res(rm_msg_ctx, env);
terminate_seq = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env);
terminate_seq_res = sandesha2_msg_ctx_get_terminate_seq_res(rm_msg_ctx, env);
seq_ack = sandesha2_msg_ctx_get_seq_ack(rm_msg_ctx, env);
seq = sandesha2_msg_ctx_get_sequence(rm_msg_ctx, env);
ack_request = sandesha2_msg_ctx_get_ack_requested(rm_msg_ctx, env);
close_seq = sandesha2_msg_ctx_get_close_seq(rm_msg_ctx, env);
close_seq_res = sandesha2_msg_ctx_get_close_seq_res(rm_msg_ctx, env);
make_conn = sandesha2_msg_ctx_get_make_connection(rm_msg_ctx, env);
/* Setting message type */
if(create_seq)
{
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_CREATE_SEQ);
}
else if(create_seq_res)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_CREATE_SEQ_RESPONSE);
idf = sandesha2_create_seq_res_get_identifier(create_seq_res, env);
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else if(terminate_seq)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_TERMINATE_SEQ);
idf = sandesha2_terminate_seq_get_identifier(terminate_seq, env);
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else if(terminate_seq_res)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_TERMINATE_SEQ_RESPONSE);
idf = sandesha2_terminate_seq_res_get_identifier(terminate_seq_res, env);
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else if(seq)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_APPLICATION);
idf = sandesha2_seq_get_identifier(seq, env);
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else if(ack_request)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_ACK_REQUEST);
idf = sandesha2_ack_requested_get_identifier(ack_request, env);
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else if(close_seq)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_CLOSE_SEQ);
idf = sandesha2_close_seq_get_identifier(close_seq, env);
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else if(close_seq_res)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_CLOSE_SEQ_RESPONSE);
idf = sandesha2_close_seq_res_get_identifier(close_seq_res, env);
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else if(make_conn)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_mc_address_t *address = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env, SANDESHA2_MSG_TYPE_MAKE_CONNECTION_MSG);
idf = sandesha2_make_connection_get_identifier(make_conn, env);
address = sandesha2_make_connection_get_address(make_conn, env);
if(idf)
{
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else if(address)
{
/* TODO Get seq_id based on the anonymous address */
}
else
{
AXIS2_ERROR_SET(env->error,
SANDESHA2_ERROR_INVALID_MAKE_CONNECTION_MSG, AXIS2_FAILURE);
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
"[sandesha2]Invalid MakeConnection message. Either Address "\
"or Identifier must be present");
if(seq_prop_mgr)
sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
return AXIS2_FALSE;
}
}
else if(seq_ack)
{
sandesha2_identifier_t *idf = NULL;
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env,
SANDESHA2_MSG_TYPE_ACK);
idf = sandesha2_seq_ack_get_identifier(seq_ack, env);
seq_id = sandesha2_identifier_get_identifier(idf, env);
}
else
{
sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env, SANDESHA2_MSG_TYPE_UNKNOWN);
}
temp_flow = axis2_msg_ctx_get_flow(temp_msg_ctx, env);
if(temp_flow == AXIS2_IN_FLOW)
{
prop_key = axutil_strdup(env, seq_id);
}
else
{
sandesha2_seq_property_bean_t *internal_seq_id_bean = NULL;
internal_seq_id_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr,
env, seq_id, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID);
if(internal_seq_id_bean)
{
prop_key = axutil_strdup(env, sandesha2_seq_property_bean_get_value(
internal_seq_id_bean, env));
sandesha2_seq_property_bean_free(internal_seq_id_bean, env);
}
}
rm_ns = sandesha2_msg_ctx_get_rm_ns_val(rm_msg_ctx, env);
if(seq_id)
{
axis2_char_t *spec_version = NULL;
axis2_char_t *seq_rm_ns = NULL;
spec_version = sandesha2_utils_get_rm_version(env, temp_msg_ctx);
if(prop_key)
{
AXIS2_FREE(env->allocator, prop_key);
prop_key = NULL;
}
if(spec_version)
{
seq_rm_ns = sandesha2_spec_specific_consts_get_rm_ns_val(env,
spec_version);
}
if(seq_rm_ns && rm_ns)
{
if(0 != axutil_strcmp(seq_rm_ns, rm_ns))
{
AXIS2_ERROR_SET(env->error,
SANDESHA2_ERROR_RM_NS_VALUE_IS_DIFFERENT_FROM_REGISTERED_NS_FOR_SEQ,
AXIS2_FAILURE);
if(seq_prop_mgr)
sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
return AXIS2_FALSE;
}
}
}
if(prop_key)
AXIS2_FREE(env->allocator, prop_key);
if(seq_prop_mgr)
sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
"[sandesha2]Exit:validate_msg");
return AXIS2_TRUE;
}