Commit 44355e1a authored by gauthier's avatar gauthier

Receiving setupresponse success, TBC

parent 610e07a9
......@@ -283,6 +283,22 @@ const char * const et_chunk_type_cid2str(const sctp_cid_t chunk_type)
}
}
//------------------------------------------------------------------------------
const char * const et_error_match2str(const int err)
{
switch (err) {
case -ET_ERROR_MATCH_PACKET_SCTP_CHUNK_TYPE: return "SCTP_CHUNK_TYPE"; break;
case -ET_ERROR_MATCH_PACKET_SCTP_PPID: return "SCTP_PPID"; break;
case -ET_ERROR_MATCH_PACKET_SCTP_ASSOC_ID: return "SCTP_ASSOC_ID"; break;
case -ET_ERROR_MATCH_PACKET_SCTP_STREAM_ID: return "SCTP_STREAM_ID"; break;
case -ET_ERROR_MATCH_PACKET_SCTP_SSN: return "SCTP_SSN"; break;
case -ET_ERROR_MATCH_PACKET_S1AP_PRESENT: return "S1AP_PRESENT"; break;
case -ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE: return "S1AP_PROCEDURE_CODE"; break;
case -ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY: return "S1AP_CRITICALITY"; break;
default:
AssertFatal (0, "ERROR: Unknown match error %d!(TODO handle an1c error codes)\n", err);
}
}
//------------------------------------------------------------------------------
et_packet_action_t et_action_str2et_action_t(const xmlChar * const action)
{
if ((!xmlStrcmp(action, (const xmlChar *)"SEND"))) { return ET_PACKET_ACTION_S1C_SEND;}
......
......@@ -178,6 +178,19 @@ typedef enum {
ET_FSM_STATE_END
} et_fsm_state_t;
typedef enum {
ET_ERROR_MATCH_START = 1,
ET_ERROR_MATCH_PACKET_SCTP_CHUNK_TYPE = ET_ERROR_MATCH_START,
ET_ERROR_MATCH_PACKET_SCTP_PPID,
ET_ERROR_MATCH_PACKET_SCTP_ASSOC_ID,
ET_ERROR_MATCH_PACKET_SCTP_STREAM_ID,
ET_ERROR_MATCH_PACKET_SCTP_SSN,
ET_ERROR_MATCH_PACKET_S1AP_PRESENT,
ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE,
ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY,
ET_ERROR_MATCH_END
} et_error_match_code_t;
......@@ -332,9 +345,9 @@ typedef struct et_scenario_s {
hash_table_t *hash_old_ue_mme_id2ue_mme_id;
struct timeval time_last_tx_packet;
struct timeval time_last_rx_packet;
et_packet_t *last_rx_packet;
et_packet_t *last_tx_packet;
et_packet_t *next_packet;
et_packet_t *last_rx_packet; // last packet received with all previous scenario RX packet received.
et_packet_t *last_tx_packet; // last sent packet
et_packet_t *next_packet; // next packet to be handled in the scenario (RX or TX packet)
} et_scenario_t;
......@@ -402,6 +415,7 @@ s1ap_eNB_instance_t *et_s1ap_eNB_get_instance(instance_t instance);
void et_s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,uint32_t buffer_length, uint16_t stream);
int et_s1ap_is_matching(et_s1ap_t * const s1ap1, et_s1ap_t * const s1ap2, const uint32_t constraints);
et_packet_t* et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t * const s1ap_data_ind);
void et_scenario_set_packet_received(et_packet_t * const packet);
void et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t * const sctp_data_ind);
void et_s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t * const sctp_data_ind);
void et_s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
......@@ -450,6 +464,7 @@ int et_compare_et_ip_to_net_ip_address(const et_ip_t * const ip, const net_ip_ad
int et_hex2data(unsigned char * const data, const unsigned char * const hexstring, const unsigned int len);
sctp_cid_t et_chunk_type_str2cid(const xmlChar * const chunk_type_str);
const char * const et_chunk_type_cid2str(const sctp_cid_t chunk_type);
const char * const et_error_match2str(const int err);
et_packet_action_t et_action_str2et_action_t(const xmlChar * const action);
void et_ip_str2et_ip(const xmlChar * const ip_str, et_ip_t * const ip);
void et_enb_config_init(const char const * lib_config_file_name_pP);
......
......@@ -273,6 +273,28 @@ void et_display_packet(const et_packet_t * const packet)
default:
fprintf(stdout, "\tPacket:\tAction UNKNOWN\n");
}
switch(packet->status) {
case ET_PACKET_STATUS_NONE:
fprintf(stdout, "\tPacket:\tStatus NONE\n");
break;
case ET_PACKET_STATUS_NOT_TAKEN_IN_ACCOUNT:
fprintf(stdout, "\tPacket:\tStatus NOT_TAKEN_IN_ACCOUNT\n");
break;
case ET_PACKET_STATUS_SCHEDULED_FOR_SENDING:
fprintf(stdout, "\tPacket:\tStatus SCHEDULED_FOR_SENDING\n");
break;
case ET_PACKET_STATUS_SENT:
fprintf(stdout, "\tPacket:\tStatus SENT\n");
break;
case ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING:
fprintf(stdout, "\tPacket:\tStatus SCHEDULED_FOR_RECEIVING\n");
break;
case ET_PACKET_STATUS_RECEIVED:
fprintf(stdout, "\tPacket:\tStatus RECEIVED\n");
break;
default:
fprintf(stdout, "\tPacket:\tStatus UNKNOWN\n");
}
et_display_packet_ip(&packet->ip_hdr);
et_display_packet_sctp(&packet->sctp_hdr);
}
......
......@@ -292,7 +292,10 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
case ET_EVENT_INIT:
AssertFatal(NULL == g_scenario, "Current scenario not ended");
g_scenario = event.u.init.scenario;
g_scenario->next_packet = g_scenario->list_packet;
g_scenario->next_packet = g_scenario->list_packet;
g_scenario->last_rx_packet = NULL;
g_scenario->last_tx_packet = NULL;
while (NULL != g_scenario->next_packet) {
switch (g_scenario->next_packet->sctp_hdr.chunk_type) {
......
......@@ -191,21 +191,21 @@ void et_s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id,
//------------------------------------------------------------------------------
int et_s1ap_is_matching(et_s1ap_t * const s1ap1, et_s1ap_t * const s1ap2, const uint32_t constraints)
{
if (s1ap1->pdu.present != s1ap2->pdu.present) return -6;
if (s1ap1->pdu.present != s1ap2->pdu.present) return -ET_ERROR_MATCH_PACKET_S1AP_PRESENT;
switch (s1ap1->pdu.present) {
case S1AP_PDU_PR_NOTHING:
break;
case S1AP_PDU_PR_initiatingMessage:
if (s1ap1->pdu.choice.initiatingMessage.procedureCode != s1ap2->pdu.choice.initiatingMessage.procedureCode) return -7;
if (s1ap1->pdu.choice.initiatingMessage.criticality != s1ap2->pdu.choice.initiatingMessage.criticality) return -8;
if (s1ap1->pdu.choice.initiatingMessage.procedureCode != s1ap2->pdu.choice.initiatingMessage.procedureCode) return -ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE;
if (s1ap1->pdu.choice.initiatingMessage.criticality != s1ap2->pdu.choice.initiatingMessage.criticality) return -ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY;
break;
case S1AP_PDU_PR_successfulOutcome:
if (s1ap1->pdu.choice.successfulOutcome.procedureCode != s1ap2->pdu.choice.successfulOutcome.procedureCode) return -7;
if (s1ap1->pdu.choice.successfulOutcome.criticality != s1ap2->pdu.choice.successfulOutcome.criticality) return -8;
if (s1ap1->pdu.choice.successfulOutcome.procedureCode != s1ap2->pdu.choice.successfulOutcome.procedureCode) return -ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE;
if (s1ap1->pdu.choice.successfulOutcome.criticality != s1ap2->pdu.choice.successfulOutcome.criticality) return -ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY;
break;
case S1AP_PDU_PR_unsuccessfulOutcome:
if (s1ap1->pdu.choice.unsuccessfulOutcome.procedureCode != s1ap2->pdu.choice.unsuccessfulOutcome.procedureCode) return -7;
if (s1ap1->pdu.choice.unsuccessfulOutcome.criticality != s1ap2->pdu.choice.unsuccessfulOutcome.criticality) return -8;
if (s1ap1->pdu.choice.unsuccessfulOutcome.procedureCode != s1ap2->pdu.choice.unsuccessfulOutcome.procedureCode) return -ET_ERROR_MATCH_PACKET_S1AP_PROCEDURE_CODE;
if (s1ap1->pdu.choice.unsuccessfulOutcome.criticality != s1ap2->pdu.choice.unsuccessfulOutcome.criticality) return -ET_ERROR_MATCH_PACKET_S1AP_CRITICALITY;
break;
default:
AssertFatal(0, "Unknown pdu.present %d", s1ap1->pdu.present);
......@@ -236,7 +236,8 @@ et_packet_t* et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t * const
packet->enb_instance = 0; //TODO
//packet->ip_hdr;
// keep in mind: allocated buffer: sctp_datahdr.payload.binary_stream
memcpy((void*)&packet->sctp_hdr, (void*)&s1ap_data_ind->sctp_datahdr, sizeof(packet->sctp_hdr));
packet->sctp_hdr.chunk_type = SCTP_CID_DATA;
memcpy((void*)&packet->sctp_hdr.u.data_hdr, (void*)&s1ap_data_ind->sctp_datahdr, sizeof(packet->sctp_hdr));
//packet->next = NULL;
packet->status = ET_PACKET_STATUS_RECEIVED;
//packet->timer_id = 0;
......@@ -245,23 +246,54 @@ et_packet_t* et_build_packet_from_s1ap_data_ind(et_event_s1ap_data_ind_t * const
}
//------------------------------------------------------------------------------
void et_scenario_set_packet_received(et_packet_t * const packet)
{
int rc = 0;
packet->status = ET_PACKET_STATUS_RECEIVED;
S1AP_DEBUG("Packet num %d received\n", packet->packet_number);
if (packet->timer_id != 0) {
rc = timer_remove(packet->timer_id);
AssertFatal(rc == 0, "Timer on Rx packet num %d unknown", packet->packet_number);
}
}
//------------------------------------------------------------------------------
void et_s1ap_process_rx_packet(et_event_s1ap_data_ind_t * const s1ap_data_ind)
{
et_packet_t * packet = NULL;
et_packet_t * rx_packet = NULL;
unsigned long int not_found = 1;
long rv = 0;
AssertFatal (NULL != s1ap_data_ind, "Bad parameter sctp_data_ind\n");
rx_packet = et_build_packet_from_s1ap_data_ind(s1ap_data_ind);
packet = g_scenario->next_packet;
if (NULL == g_scenario->last_rx_packet) {
packet = g_scenario->list_packet;
while (NULL != packet) {
if (packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
if (packet->status == ET_PACKET_STATUS_RECEIVED) {
g_scenario->last_rx_packet = packet;
} else {
break;
}
}
packet = packet->next;
}
packet = g_scenario->list_packet;
} else {
packet = g_scenario->last_rx_packet;
}
// not_found threshold may sure depend on number of mme, may be not sure on number of UE
while ((NULL != packet) && (not_found < 5)) {
if (packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
//TODO
if (et_sctp_is_matching(&packet->sctp_hdr, &rx_packet->sctp_hdr, g_constraints) == 0) {
rv = et_sctp_is_matching(&packet->sctp_hdr, &rx_packet->sctp_hdr, g_constraints);
if (0 == rv) {
S1AP_DEBUG("Compare RX packet with packet num %d succeeded\n", packet->packet_number);
et_scenario_set_packet_received(packet);
} else {
S1AP_DEBUG("Compare RX packet with packet num %d failed %s\n", packet->packet_number, et_error_match2str(rv));
}
}
not_found += 1;
......@@ -388,9 +420,9 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
case SCTP_CID_DATA :
S1AP_DEBUG("%s for SCTP association (%u) SCTP_CID_DATA\n",__FUNCTION__,assoc_id);
if (ET_PACKET_STATUS_NONE == packet->status) {
if ((ET_PACKET_STATUS_NONE == packet->status) || (ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING == packet->status)) {
if (0 < old_mme_port) {
if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_SEND) {
if (packet->action == ET_PACKET_ACTION_S1C_SEND) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &mme_desc_p->mme_net_ip_address);
if (0 == ret) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &s1ap_eNB_instance->s1c_net_ip_address);
......@@ -403,7 +435,7 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
}
}
}
} else if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
} else if (packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &mme_desc_p->mme_net_ip_address);
if (0 == ret) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &s1ap_eNB_instance->s1c_net_ip_address);
......@@ -474,6 +506,7 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
break;
default:
AssertFatal(0, "Unknown chunk_type %d packet num %d", packet->sctp_hdr.chunk_type, packet->packet_number);
;
}
packet = packet->next;
......
......@@ -47,20 +47,26 @@
int et_sctp_data_is_matching(sctp_datahdr_t * const sctp1, sctp_datahdr_t * const sctp2, const uint32_t constraints)
{
// no comparison for ports
if (sctp1->ppid != sctp2->ppid) return -4;
if (sctp1->assoc_id != sctp2->assoc_id) return -5;
if (sctp1->ppid != sctp2->ppid) {
S1AP_WARN("No Matching SCTP PPID %u %u\n", sctp1->ppid, sctp2->ppid);
return -ET_ERROR_MATCH_PACKET_SCTP_PPID;
}
if (sctp1->assoc_id != sctp2->assoc_id) {
S1AP_WARN("No Matching SCTP assoc id %u %u\n", sctp1->assoc_id, sctp2->assoc_id);
return -ET_ERROR_MATCH_PACKET_SCTP_ASSOC_ID;
}
if (sctp1->stream != sctp2->stream) {
if (constraints & ET_BIT_MASK_MATCH_SCTP_STREAM) {
return -2;
return -ET_ERROR_MATCH_PACKET_SCTP_STREAM_ID;
} else {
S1AP_WARN("No Matching SCTP stream %u %u\n", sctp1->stream, sctp2->stream);
}
}
if (sctp1->ssn != sctp2->ssn) {
if (constraints & ET_BIT_MASK_MATCH_SCTP_SSN) {
return -3;
return -ET_ERROR_MATCH_PACKET_SCTP_SSN;
} else {
S1AP_WARN("No Matching SCTP ssn %u %u\n", sctp1->ssn, sctp2->ssn);
S1AP_WARN("No Matching SCTP STREAM SN %u %u\n", sctp1->ssn, sctp2->ssn);
}
}
return et_s1ap_is_matching(&sctp1->payload, &sctp2->payload, constraints);
......@@ -70,7 +76,7 @@ int et_sctp_data_is_matching(sctp_datahdr_t * const sctp1, sctp_datahdr_t * cons
int et_sctp_is_matching(et_sctp_hdr_t * const sctp1, et_sctp_hdr_t * const sctp2, const uint32_t constraints)
{
// no comparison for ports
if (sctp1->chunk_type != sctp2->chunk_type) return -1;
if (sctp1->chunk_type != sctp2->chunk_type) return -ET_ERROR_MATCH_PACKET_SCTP_CHUNK_TYPE;
switch (sctp1->chunk_type) {
case SCTP_CID_DATA:
return et_sctp_data_is_matching(&sctp1->u.data_hdr, &sctp2->u.data_hdr, constraints);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment