Identity Request/Response is added

This commit is contained in:
Sukchan Lee 2017-03-21 15:02:16 +09:00
parent e51e4d4c30
commit 3facb91b1e
10 changed files with 219 additions and 5 deletions

View File

@ -26,7 +26,7 @@
/*******************************************************************************
* This file had been created by gtpv2c_tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2017-03-21 13:53:30.272010 by acetcom
* Created on: 2017-03-21 13:59:52.534215 by acetcom
* from 24301-d80.docx
******************************************************************************/
@ -415,6 +415,32 @@ c_int32_t nas_decode_authentication_response(nas_message_t *message, pkbuf_t *pk
return decoded;
}
c_int32_t nas_decode_identity_request(nas_message_t *message, pkbuf_t *pkbuf)
{
nas_identity_request_t *identity_request = &message->identity_request;
c_int32_t decoded = 0;
c_int32_t size = 0;
size = nas_decode_identity_type_2(&identity_request->identity_type, pkbuf);
d_assert(size >= 0, return -1, "decode failed");
decoded += size;
return decoded;
}
c_int32_t nas_decode_identity_response(nas_message_t *message, pkbuf_t *pkbuf)
{
nas_identity_response_t *identity_response = &message->identity_response;
c_int32_t decoded = 0;
c_int32_t size = 0;
size = nas_decode_mobile_identity(&identity_response->mobile_identity, pkbuf);
d_assert(size >= 0, return -1, "decode failed");
decoded += size;
return decoded;
}
c_int32_t nas_decode_authentication_failure(nas_message_t *message, pkbuf_t *pkbuf)
{
nas_authentication_failure_t *authentication_failure = &message->authentication_failure;
@ -604,6 +630,16 @@ status_t nas_plain_decode(nas_message_t *message, pkbuf_t *pkbuf)
d_assert(size >= CORE_OK, return CORE_ERROR, "decode error");
decoded += size;
break;
case NAS_IDENTITY_REQUEST:
size = nas_decode_identity_request(message, pkbuf);
d_assert(size >= CORE_OK, return CORE_ERROR, "decode error");
decoded += size;
break;
case NAS_IDENTITY_RESPONSE:
size = nas_decode_identity_response(message, pkbuf);
d_assert(size >= CORE_OK, return CORE_ERROR, "decode error");
decoded += size;
break;
case NAS_AUTHENTICATION_FAILURE:
size = nas_decode_authentication_failure(message, pkbuf);
d_assert(size >= CORE_OK, return CORE_ERROR, "decode error");

View File

@ -26,7 +26,7 @@
/*******************************************************************************
* This file had been created by gtpv2c_tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2017-03-21 13:53:30.276503 by acetcom
* Created on: 2017-03-21 13:59:52.538701 by acetcom
* from 24301-d80.docx
******************************************************************************/
@ -527,6 +527,32 @@ c_int32_t nas_encode_authentication_response(pkbuf_t *pkbuf, nas_message_t *mess
return encoded;
}
c_int32_t nas_encode_identity_request(pkbuf_t *pkbuf, nas_message_t *message)
{
nas_identity_request_t *identity_request = &message->identity_request;
c_int32_t encoded = 0;
c_int32_t size = 0;
size = nas_encode_identity_type_2(pkbuf, &identity_request->identity_type);
d_assert(size >= 0, return -1, "encode failed");
encoded += size;
return encoded;
}
c_int32_t nas_encode_identity_response(pkbuf_t *pkbuf, nas_message_t *message)
{
nas_identity_response_t *identity_response = &message->identity_response;
c_int32_t encoded = 0;
c_int32_t size = 0;
size = nas_encode_mobile_identity(pkbuf, &identity_response->mobile_identity);
d_assert(size >= 0, return -1, "encode failed");
encoded += size;
return encoded;
}
c_int32_t nas_encode_authentication_failure(pkbuf_t *pkbuf, nas_message_t *message)
{
nas_authentication_failure_t *authentication_failure = &message->authentication_failure;
@ -689,6 +715,16 @@ status_t nas_plain_encode(pkbuf_t **pkbuf, nas_message_t *message)
d_assert(size >= 0, return CORE_ERROR, "decode error");
encoded += size;
break;
case NAS_IDENTITY_REQUEST:
size = nas_encode_identity_request(*pkbuf, message);
d_assert(size >= 0, return CORE_ERROR, "decode error");
encoded += size;
break;
case NAS_IDENTITY_RESPONSE:
size = nas_encode_identity_response(*pkbuf, message);
d_assert(size >= 0, return CORE_ERROR, "decode error");
encoded += size;
break;
case NAS_AUTHENTICATION_FAILURE:
size = nas_encode_authentication_failure(*pkbuf, message);
d_assert(size >= 0, return CORE_ERROR, "decode error");

View File

@ -26,7 +26,7 @@
/*******************************************************************************
* This file had been created by gtpv2c_tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2017-03-21 13:53:30.260104 by acetcom
* Created on: 2017-03-21 13:59:52.523461 by acetcom
* from 24301-d80.docx
******************************************************************************/
@ -546,6 +546,30 @@ c_int16_t nas_encode_gprs_timer_3(pkbuf_t *pkbuf, nas_gprs_timer_3_t *gprs_timer
return size;
}
/* 9.9.3.17 Identity type 2
* M V 1/2 */
c_int16_t nas_decode_identity_type_2(nas_identity_type_2_t *identity_type_2, pkbuf_t *pkbuf)
{
c_uint16_t size = sizeof(nas_identity_type_2_t);
d_assert(pkbuf_header(pkbuf, -size) == CORE_OK, return -1, "pkbuf_header error");
memcpy(identity_type_2, pkbuf->payload - size, size);
return size;
}
c_int16_t nas_encode_identity_type_2(pkbuf_t *pkbuf, nas_identity_type_2_t *identity_type_2)
{
c_uint16_t size = sizeof(nas_identity_type_2_t);
nas_identity_type_2_t target;
memcpy(&target, identity_type_2, size);
d_assert(pkbuf_header(pkbuf, -size) == CORE_OK, return -1, "pkbuf_header error");
memcpy(pkbuf->payload - size, &target, size);
return size;
}
/* 9.9.3.18 IMEISV request
* O TV 1 */
c_int16_t nas_decode_imeisv_request(nas_imeisv_request_t *imeisv_request, pkbuf_t *pkbuf)

View File

@ -26,7 +26,7 @@
/*******************************************************************************
* This file had been created by gtpv2c_tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2017-03-21 13:53:30.257303 by acetcom
* Created on: 2017-03-21 13:59:52.520739 by acetcom
* from 24301-d80.docx
******************************************************************************/
@ -60,6 +60,7 @@ CORE_DECLARE(c_int16_t) nas_decode_esm_message_container(nas_esm_message_contain
CORE_DECLARE(c_int16_t) nas_decode_gprs_timer(nas_gprs_timer_t *gprs_timer, pkbuf_t *pkbuf);
CORE_DECLARE(c_int16_t) nas_decode_gprs_timer_2(nas_gprs_timer_2_t *gprs_timer_2, pkbuf_t *pkbuf);
CORE_DECLARE(c_int16_t) nas_decode_gprs_timer_3(nas_gprs_timer_3_t *gprs_timer_3, pkbuf_t *pkbuf);
CORE_DECLARE(c_int16_t) nas_decode_identity_type_2(nas_identity_type_2_t *identity_type_2, pkbuf_t *pkbuf);
CORE_DECLARE(c_int16_t) nas_decode_imeisv_request(nas_imeisv_request_t *imeisv_request, pkbuf_t *pkbuf);
CORE_DECLARE(c_int16_t) nas_decode_authentication_parameter_autn(nas_authentication_parameter_autn_t *authentication_parameter_autn, pkbuf_t *pkbuf);
CORE_DECLARE(c_int16_t) nas_decode_ms_network_capability(nas_ms_network_capability_t *ms_network_capability, pkbuf_t *pkbuf);
@ -102,6 +103,7 @@ CORE_DECLARE(c_int16_t) nas_encode_esm_message_container(pkbuf_t *pkbuf, nas_esm
CORE_DECLARE(c_int16_t) nas_encode_gprs_timer(pkbuf_t *pkbuf, nas_gprs_timer_t *gprs_timer);
CORE_DECLARE(c_int16_t) nas_encode_gprs_timer_2(pkbuf_t *pkbuf, nas_gprs_timer_2_t *gprs_timer_2);
CORE_DECLARE(c_int16_t) nas_encode_gprs_timer_3(pkbuf_t *pkbuf, nas_gprs_timer_3_t *gprs_timer_3);
CORE_DECLARE(c_int16_t) nas_encode_identity_type_2(pkbuf_t *pkbuf, nas_identity_type_2_t *identity_type_2);
CORE_DECLARE(c_int16_t) nas_encode_imeisv_request(pkbuf_t *pkbuf, nas_imeisv_request_t *imeisv_request);
CORE_DECLARE(c_int16_t) nas_encode_authentication_parameter_autn(pkbuf_t *pkbuf, nas_authentication_parameter_autn_t *authentication_parameter_autn);
CORE_DECLARE(c_int16_t) nas_encode_ms_network_capability(pkbuf_t *pkbuf, nas_ms_network_capability_t *ms_network_capability);

View File

@ -26,7 +26,7 @@
/*******************************************************************************
* This file had been created by gtpv2c_tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2017-03-21 13:53:30.267686 by acetcom
* Created on: 2017-03-21 13:59:52.530233 by acetcom
* from 24301-d80.docx
******************************************************************************/
@ -306,6 +306,26 @@ typedef struct _nas_authentication_response_t {
} nas_authentication_response_t;
/*******************************************************
* IDENTITY REQUEST
******************************************************/
typedef struct _nas_identity_request_t {
/* Mandatory fields */
nas_identity_type_2_t identity_type;
} nas_identity_request_t;
/*******************************************************
* IDENTITY RESPONSE
******************************************************/
typedef struct _nas_identity_response_t {
/* Mandatory fields */
nas_mobile_identity_t mobile_identity;
} nas_identity_response_t;
/*******************************************************
* AUTHENTICATION FAILURE
******************************************************/
@ -379,6 +399,8 @@ typedef struct _nas_message_t {
nas_attach_reject_t attach_reject;
nas_authentication_request_t authentication_request;
nas_authentication_response_t authentication_response;
nas_identity_request_t identity_request;
nas_identity_response_t identity_response;
nas_authentication_failure_t authentication_failure;
nas_security_mode_command_t security_mode_command;
nas_security_mode_complete_t security_mode_complete;

View File

@ -395,6 +395,18 @@ ED2(c_uint8_t unit:3;,
c_uint8_t timer_value:5;)
} __attribute__ ((packed)) nas_gprs_timer_3_t;
/* 9.9.3.17 Identity type 2
* See subclause 10.5.5.9 in 3GPP TS 24.008 [13].
* M V 1/2 */
#define NAS_IDENTITY_IMSI_TYPE 1
#define NAS_IDENTITY_IMEI_TYPE 2
#define NAS_IDENTITY_IMEISV_TYPE 3
#define NAS_IDENTITY_TMSI_TYPE 4
typedef struct _nas_identity_type_2_t {
ED2(c_uint8_t spare:5;,
c_uint8_t type_of_identity:3;)
} __attribute__ ((packed)) nas_identity_type_2_t;
/* 9.9.3.18 IMEISV request
* See subclause 10.5.5.10 in 3GPP TS 24.008 [13].
* O TV 1 */

3
lib/nas/support/cache/nas_msg_85.py vendored Normal file
View File

@ -0,0 +1,3 @@
ies = []
ies.append({ "iei" : "", "value" : "Identity type", "type" : "Identity type 2", "reference" : "9.9.3.17", "presence" : "M", "format" : "V", "length" : "1/2"})
msg_list[key]["ies"] = ies

3
lib/nas/support/cache/nas_msg_86.py vendored Normal file
View File

@ -0,0 +1,3 @@
ies = []
ies.append({ "iei" : "", "value" : "Mobile identity", "type" : "Mobile identity", "reference" : "9.9.2.3", "presence" : "M", "format" : "LV", "length" : "4-10"})
msg_list[key]["ies"] = ies

View File

@ -214,6 +214,8 @@ msg_list["ATTACH REQUEST"]["table"] = 11
msg_list["AUTHENTICATION FAILURE"]["table"] = 12
msg_list["AUTHENTICATION REQUEST"]["table"] = 14
msg_list["AUTHENTICATION RESPONSE"]["table"] = 15
msg_list["IDENTITY REQUEST"]["table"] = 27
msg_list["IDENTITY RESPONSE"]["table"] = 28
msg_list["SECURITY MODE COMMAND"]["table"] = 29
msg_list["SECURITY MODE COMPLETE"]["table"] = 30
msg_list["SECURITY MODE REJECT"]["table"] = 31

View File

@ -182,6 +182,78 @@ static void nas_message_test5(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, 0xabcdef, ue.ul_count.i32);
}
static void nas_message_test6(abts_case *tc, void *data)
{
/* Identity Request */
char *payload = "075501";
nas_message_t message;
nas_identity_request_t *identity_request = &message.identity_request;
pkbuf_t *pkbuf;
status_t rv;
pkbuf = pkbuf_alloc(0, MESSAGE_SDU_SIZE);
ABTS_PTR_NOTNULL(tc, pkbuf);
pkbuf->len = 3;
core_ascii_to_hex(payload, strlen(payload), pkbuf->payload, pkbuf->len);
rv = nas_plain_decode(&message, pkbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
ABTS_INT_EQUAL(tc, NAS_PROTOCOL_DISCRIMINATOR_EMM,
message.h.protocol_discriminator);
ABTS_INT_EQUAL(tc, NAS_IDENTITY_REQUEST, message.h.message_type);
ABTS_INT_EQUAL(tc, NAS_IDENTITY_IMSI_TYPE,
identity_request->identity_type.type_of_identity);
pkbuf_free(pkbuf);
}
static void nas_message_test7(abts_case *tc, void *data)
{
/* Identity Response */
char *payload = "0756080910101032548651";
char buffer[11];
nas_message_t message;
nas_identity_response_t *identity_response = &message.identity_response;
pkbuf_t *pkbuf = NULL;
status_t rv;
memset(&message, 0, sizeof(message));
message.h.protocol_discriminator = NAS_PROTOCOL_DISCRIMINATOR_EMM;
message.h.message_type = NAS_IDENTITY_RESPONSE;
identity_response->mobile_identity.length = 8;
identity_response->mobile_identity.imsi.digit1 = 0;
identity_response->mobile_identity.imsi.type_of_identity = NAS_MOBILE_IDENTITY_IMSI;
identity_response->mobile_identity.imsi.odd_even = 1;
identity_response->mobile_identity.imsi.digit2 = 0;
identity_response->mobile_identity.imsi.digit3 = 1;
identity_response->mobile_identity.imsi.digit4 = 0;
identity_response->mobile_identity.imsi.digit5 = 1;
identity_response->mobile_identity.imsi.digit6 = 0;
identity_response->mobile_identity.imsi.digit7 = 1;
identity_response->mobile_identity.imsi.digit8 = 2;
identity_response->mobile_identity.imsi.digit9 = 3;
identity_response->mobile_identity.imsi.digit10 = 4;
identity_response->mobile_identity.imsi.digit11 = 5;
identity_response->mobile_identity.imsi.digit12 = 6;
identity_response->mobile_identity.imsi.digit13 = 8;
identity_response->mobile_identity.imsi.digit14 = 1;
identity_response->mobile_identity.imsi.digit15 = 5;
rv = nas_plain_encode(&pkbuf, &message);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
ABTS_INT_EQUAL(tc, sizeof(buffer), pkbuf->len);
ABTS_TRUE(tc, memcmp(
core_ascii_to_hex(payload, strlen(payload), buffer, sizeof(buffer)),
pkbuf->payload, pkbuf->len) == 0);
pkbuf_free(pkbuf);
}
abts_suite *test_nas_message(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@ -191,6 +263,8 @@ abts_suite *test_nas_message(abts_suite *suite)
abts_run_test(suite, nas_message_test3, NULL);
abts_run_test(suite, nas_message_test4, NULL);
abts_run_test(suite, nas_message_test5, NULL);
abts_run_test(suite, nas_message_test6, NULL);
abts_run_test(suite, nas_message_test7, NULL);
return suite;
}