int encode_bearer_resource_allocation_reject(bearer_resource_allocation_reject_msg *bearer_resource_allocation_reject, uint8_t *buffer, uint32_t len) { int encoded = 0; int encode_result = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, BEARER_RESOURCE_ALLOCATION_REJECT_MINIMUM_LENGTH, len); if ((encode_result = encode_esm_cause(&bearer_resource_allocation_reject->esmcause, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error return encode_result; else encoded += encode_result; if ((bearer_resource_allocation_reject->presencemask & BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) == BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) { if ((encode_result = encode_protocol_configuration_options(&bearer_resource_allocation_reject->protocolconfigurationoptions, BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI, buffer + encoded, len - encoded)) < 0) // Return in case of error return encode_result; else encoded += encode_result; } return encoded; }
int encode_tracking_area_identity(TrackingAreaIdentity *trackingareaidentity, uint8_t iei, uint8_t *buffer, uint32_t len) { uint32_t encoded = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, TRACKING_AREA_IDENTITY_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_tracking_area_identity_xml(trackingareaidentity, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } *(buffer + encoded) = 0x00 | ((trackingareaidentity->mccdigit2 & 0xf) << 4) | (trackingareaidentity->mccdigit1 & 0xf); encoded++; *(buffer + encoded) = 0x00 | ((trackingareaidentity->mncdigit3 & 0xf) << 4) | (trackingareaidentity->mccdigit3 & 0xf); encoded++; *(buffer + encoded) = 0x00 | ((trackingareaidentity->mncdigit2 & 0xf) << 4) | (trackingareaidentity->mncdigit1 & 0xf); encoded++; IES_ENCODE_U16(buffer, encoded, trackingareaidentity->tac); return encoded; }
int encode_voice_domain_preference_and_ue_usage_setting ( VoiceDomainPreferenceAndUeUsageSetting * voicedomainpreferenceandueusagesetting, uint8_t iei, uint8_t * buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_voice_domain_preference_and_ue_usage_setting_xml (voicedomainpreferenceandueusagesetting, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded++; *(buffer + encoded) = 0x00 | (voicedomainpreferenceandueusagesetting->ue_usage_setting << 2) | voicedomainpreferenceandueusagesetting->voice_domain_for_eutran; encoded++; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_time_zone ( TimeZone * timezone, uint8_t iei, uint8_t * buffer, uint32_t len) { uint32_t encoded = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, TIME_ZONE_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_time_zone_xml (timezone, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } *(buffer + encoded) = *timezone; encoded++; return encoded; }
int encode_nas_message_container(NasMessageContainer *nasmessagecontainer, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; int encode_result; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, NAS_MESSAGE_CONTAINER_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_nas_message_container_xml(nasmessagecontainer, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded ++; if ((encode_result = encode_octet_string(&nasmessagecontainer->nasmessagecontainercontents, buffer + encoded, len - encoded)) < 0) return encode_result; else encoded += encode_result; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_lcs_client_identity(LcsClientIdentity *lcsclientidentity, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; int encode_result; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, LCS_CLIENT_IDENTITY_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_lcs_client_identity_xml(lcsclientidentity, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded ++; if ((encode_result = encode_octet_string(&lcsclientidentity->lcsclientidentityvalue, buffer + encoded, len - encoded)) < 0) return encode_result; else encoded += encode_result; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_authentication_failure_parameter(AuthenticationFailureParameter *authenticationfailureparameter, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; int encode_result; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_FAILURE_PARAMETER_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_authentication_failure_parameter_xml(authenticationfailureparameter, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded ++; if ((encode_result = encode_octet_string(&authenticationfailureparameter->auts, buffer + encoded, len - encoded)) < 0) return encode_result; else encoded += encode_result; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_nas_security_algorithms ( NasSecurityAlgorithms * nassecurityalgorithms, uint8_t iei, uint8_t * buffer, uint32_t len) { uint32_t encoded = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, NAS_SECURITY_ALGORITHMS_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_nas_security_algorithms_xml (nassecurityalgorithms, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } *(buffer + encoded) = 0x00 | ((nassecurityalgorithms->typeofcipheringalgorithm & 0x7) << 4) | (nassecurityalgorithms->typeofintegrityalgorithm & 0x7); encoded++; return encoded; }
int encode_tracking_area_identity_list(TrackingAreaIdentityList *trackingareaidentitylist, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, TRACKING_AREA_IDENTITY_LIST_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_tracking_area_identity_list_xml(trackingareaidentitylist, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded ++; *(buffer + encoded) = 0x00 | ((trackingareaidentitylist->typeoflist & 0x3) << 5) | (trackingareaidentitylist->numberofelements & 0x1f); encoded++; *(buffer + encoded) = 0x00 | ((trackingareaidentitylist->mccdigit2 & 0xf) << 4) | (trackingareaidentitylist->mccdigit1 & 0xf); encoded++; *(buffer + encoded) = 0x00 | ((trackingareaidentitylist->mncdigit3 & 0xf) << 4) | (trackingareaidentitylist->mccdigit3 & 0xf); encoded++; *(buffer + encoded) = 0x00 | ((trackingareaidentitylist->mncdigit2 & 0xf) << 4) | (trackingareaidentitylist->mncdigit1 & 0xf); encoded++; IES_ENCODE_U16(buffer, encoded, trackingareaidentitylist->tac); *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_location_area_identification(LocationAreaIdentification *locationareaidentification, uint8_t iei, uint8_t *buffer, uint32_t len) { uint32_t encoded = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, LOCATION_AREA_IDENTIFICATION_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_location_area_identification_xml(locationareaidentification, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } *(buffer + encoded) = 0x00 | ((locationareaidentification->mccdigit2 & 0xf) << 4) | (locationareaidentification->mccdigit1 & 0xf); encoded++; *(buffer + encoded) = 0x00 | ((locationareaidentification->mncdigit3 & 0xf) << 4) | (locationareaidentification->mccdigit3 & 0xf); encoded++; *(buffer + encoded) = 0x00 | ((locationareaidentification->mncdigit2 & 0xf) << 4) | (locationareaidentification->mncdigit1 & 0xf); encoded++; IES_ENCODE_U16(buffer, encoded, locationareaidentification->lac); return encoded; }
int encode_authentication_failure(authentication_failure_msg *authentication_failure, uint8_t *buffer, uint32_t len) { int encoded = 0; int encode_result = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len); if ((encode_result = encode_emm_cause(&authentication_failure->emmcause, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error return encode_result; else encoded += encode_result; if ((authentication_failure->presencemask & AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) == AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) { if ((encode_result = encode_authentication_failure_parameter(&authentication_failure->authenticationfailureparameter, AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI, buffer + encoded, len - encoded)) < 0) // Return in case of error return encode_result; else encoded += encode_result; } return encoded; }
int encode_pdn_address(PdnAddress *pdnaddress, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; int encode_result; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDN_ADDRESS_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_pdn_address_xml(pdnaddress, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded ++; *(buffer + encoded) = 0x00 | (pdnaddress->pdntypevalue & 0x7); encoded++; if ((encode_result = encode_octet_string(&pdnaddress->pdnaddressinformation, buffer + encoded, len - encoded)) < 0) return encode_result; else encoded += encode_result; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_short_mac ( ShortMac * shortmac, uint8_t iei, uint8_t * buffer, uint32_t len) { uint32_t encoded = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, SHORT_MAC_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_short_mac_xml (shortmac, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } IES_ENCODE_U16 (buffer, encoded, *shortmac); return encoded; }
int encode_authentication_request(authentication_request_msg *authentication_request, uint8_t *buffer, uint32_t len) { int encoded = 0; int encode_result = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len); *(buffer + encoded) = ((encode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifierasme) & 0x0f) << 4) | 0x00; encoded++; if ((encode_result = encode_authentication_parameter_rand(&authentication_request->authenticationparameterrand, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error return encode_result; else encoded += encode_result; if ((encode_result = encode_authentication_parameter_autn(&authentication_request->authenticationparameterautn, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error return encode_result; else encoded += encode_result; return encoded; }
int encode_pdn_disconnect_reject(pdn_disconnect_reject_msg *pdn_disconnect_reject, uint8_t *buffer, uint32_t len) { int encoded = 0; int encode_result = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDN_DISCONNECT_REJECT_MINIMUM_LENGTH, len); if ((encode_result = encode_esm_cause(&pdn_disconnect_reject->esmcause, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error return encode_result; else encoded += encode_result; if ((pdn_disconnect_reject->presencemask & PDN_DISCONNECT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) == PDN_DISCONNECT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) { if ((encode_result = encode_protocol_configuration_options(&pdn_disconnect_reject->protocolconfigurationoptions, PDN_DISCONNECT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI, buffer + encoded, len - encoded)) < 0) // Return in case of error return encode_result; else encoded += encode_result; } return encoded; }
int encode_authentication_parameter_autn ( AuthenticationParameterAutn * authenticationparameterautn, uint8_t iei, uint8_t * buffer, uint32_t len) { uint8_t *lenPtr; int encode_result; uint32_t encoded = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_PARAMETER_AUTN_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_authentication_parameter_autn_xml (authenticationparameterautn, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded++; if ((encode_result = encode_octet_string (&authenticationparameterautn->autn, buffer + encoded, len - encoded)) < 0) return encode_result; else encoded += encode_result; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_daylight_saving_time ( DaylightSavingTime * daylightsavingtime, uint8_t iei, uint8_t * buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, DAYLIGHT_SAVING_TIME_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_daylight_saving_time_xml (daylightsavingtime, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded++; *(buffer + encoded) = 0x00 | (*daylightsavingtime & 0x3); encoded++; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_activate_default_eps_bearer_context_reject(activate_default_eps_bearer_context_reject_msg *activate_default_eps_bearer_context_reject, uint8_t *buffer, uint32_t len) { int encoded = 0; int encode_result = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_MINIMUM_LENGTH, len); if ((encode_result = encode_esm_cause(&activate_default_eps_bearer_context_reject->esmcause, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error return encode_result; else encoded += encode_result; if ((activate_default_eps_bearer_context_reject->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) == ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) { if ((encode_result = encode_protocol_configuration_options(&activate_default_eps_bearer_context_reject->protocolconfigurationoptions, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI, buffer + encoded, len - encoded)) < 0) // Return in case of error return encode_result; else encoded += encode_result; } return encoded; }
int encode_service_request(service_request_msg *service_request, uint8_t *buffer, uint32_t len) { int encoded = 0; int encode_result = 0; LOG_FUNC_IN; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SERVICE_REQUEST_MINIMUM_LENGTH, len); if ((encode_result = encode_ksi_and_sequence_number(&service_request->ksiandsequencenumber, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error LOG_FUNC_RETURN(encode_result); else encoded += encode_result; if ((encode_result = encode_short_mac(&service_request->messageauthenticationcode, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error LOG_FUNC_RETURN(encode_result); else encoded += encode_result; LOG_FUNC_RETURN(encoded); }
int encode_esm_message_container(EsmMessageContainer *esmmessagecontainer, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; int32_t encode_result; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ESM_MESSAGE_CONTAINER_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_esm_message_container_xml(esmmessagecontainer, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); //encoded += 2; //if ((encode_result = encode_octet_string(&esmmessagecontainer->esmmessagecontainercontents, buffer + sizeof(uint16_t), len - sizeof(uint16_t))) < 0) if ((encode_result = encode_octet_string(&esmmessagecontainer->esmmessagecontainercontents, lenPtr + sizeof(uint16_t), len - sizeof(uint16_t))) < 0) return encode_result; else encoded += encode_result; ENCODE_U16(lenPtr, encode_result, encoded); #if 0 lenPtr[1] = (((encoded - 2 - ((iei > 0) ? 1: 0))) & 0x0000ff00) >> 8; lenPtr[0] = ((encoded - 2 - ((iei > 0) ? 1: 0))) & 0x000000ff; #endif return encoded; }
int encode_eps_quality_of_service(EpsQualityOfService *epsqualityofservice, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, EPS_QUALITY_OF_SERVICE_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_eps_quality_of_service_xml(epsqualityofservice, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded ++; *(buffer + encoded) = epsqualityofservice->qci; encoded++; if (epsqualityofservice->bitRatesPresent) { encoded += encode_eps_qos_bit_rates(&epsqualityofservice->bitRates, buffer + encoded); } if (epsqualityofservice->bitRatesExtPresent) { encoded += encode_eps_qos_bit_rates(&epsqualityofservice->bitRatesExt, buffer + encoded); } *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_eps_network_feature_support ( EpsNetworkFeatureSupport * epsnetworkfeaturesupport, uint8_t iei, uint8_t * buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, EPS_NETWORK_FEATURE_SUPPORT_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_eps_network_feature_support_xml (epsnetworkfeaturesupport, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded++; *(buffer + encoded) = 0x00 | (*epsnetworkfeaturesupport & 0x1); encoded++; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_p_tmsi_signature ( PTmsiSignature * ptmsisignature, uint8_t iei, uint8_t * buffer, uint32_t len) { uint32_t encode_result; uint32_t encoded = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, P_TMSI_SIGNATURE_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_p_tmsi_signature_xml (ptmsisignature, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } if ((encode_result = encode_octet_string (&ptmsisignature->ptmsisignaturevalue, buffer + encoded, len - encoded)) < 0) return encode_result; else encoded += encode_result; return encoded; }
int encode_ms_network_capability ( MsNetworkCapability * msnetworkcapability, uint8_t iei, uint8_t * buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; int encode_result; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, MS_NETWORK_CAPABILITY_MINIMUM_LENGTH, len); #if NAS_DEBUG dump_ms_network_capability_xml (msnetworkcapability, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded++; if ((encode_result = encode_octet_string (&msnetworkcapability->msnetworkcapabilityvalue, buffer + encoded, len - encoded)) < 0) return encode_result; else encoded += encode_result; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_esm_information_request(esm_information_request_msg *esm_information_request, uint8_t *buffer, uint32_t len) { int encoded = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ESM_INFORMATION_REQUEST_MINIMUM_LENGTH, len); return encoded; }
int encode_security_mode_command ( security_mode_command_msg * security_mode_command, uint8_t * buffer, uint32_t len) { int encoded = 0; int encode_result = 0; /* * Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, SECURITY_MODE_COMMAND_MINIMUM_LENGTH, len); if ((encode_result = encode_nas_security_algorithms (&security_mode_command->selectednassecurityalgorithms, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error return encode_result; else encoded += encode_result; *(buffer + encoded) = (encode_u8_nas_key_set_identifier (&security_mode_command->naskeysetidentifier) & 0x0f); encoded++; if ((encode_result = encode_ue_security_capability (&security_mode_command->replayeduesecuritycapabilities, 0, buffer + encoded, len - encoded)) < 0) //Return in case of error return encode_result; else encoded += encode_result; if ((security_mode_command->presencemask & SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT) == SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT) { if ((encode_result = encode_imeisv_request (&security_mode_command->imeisvrequest, SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI, buffer + encoded, len - encoded)) < 0) // Return in case of error return encode_result; else encoded += encode_result; } if ((security_mode_command->presencemask & SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_PRESENT) == SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_PRESENT) { if ((encode_result = encode_nonce (&security_mode_command->replayednonceue, SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_IEI, buffer + encoded, len - encoded)) < 0) // Return in case of error return encode_result; else encoded += encode_result; } if ((security_mode_command->presencemask & SECURITY_MODE_COMMAND_NONCEMME_PRESENT) == SECURITY_MODE_COMMAND_NONCEMME_PRESENT) { if ((encode_result = encode_nonce (&security_mode_command->noncemme, SECURITY_MODE_COMMAND_NONCEMME_IEI, buffer + encoded, len - encoded)) < 0) // Return in case of error return encode_result; else encoded += encode_result; } return encoded; }
int encode_quality_of_service(QualityOfService *qualityofservice, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t *lenPtr; uint32_t encoded = 0; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, QUALITY_OF_SERVICE_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_quality_of_service_xml(qualityofservice, iei); #endif if (iei > 0) { *buffer = iei; encoded++; } lenPtr = (buffer + encoded); encoded ++; *(buffer + encoded) = 0x00 | ((qualityofservice->delayclass & 0x7) << 3) | (qualityofservice->reliabilityclass & 0x7); encoded++; *(buffer + encoded) = 0x00 | ((qualityofservice->peakthroughput & 0xf) << 4) | (qualityofservice->precedenceclass & 0x7); encoded++; *(buffer + encoded) = 0x00 | (qualityofservice->meanthroughput & 0x1f); encoded++; *(buffer + encoded) = 0x00 | ((qualityofservice->trafficclass & 0x7) << 5) | ((qualityofservice->deliveryorder & 0x3) << 3) | (qualityofservice->deliveryoferroneoussdu & 0x7); encoded++; *(buffer + encoded) = qualityofservice->maximumsdusize; encoded++; *(buffer + encoded) = qualityofservice->maximumbitrateuplink; encoded++; *(buffer + encoded) = qualityofservice->maximumbitratedownlink; encoded++; *(buffer + encoded) = 0x00 | ((qualityofservice->residualber & 0xf) << 4) | (qualityofservice->sduratioerror & 0xf); encoded++; *(buffer + encoded) = 0x00 | ((qualityofservice->transferdelay & 0x3f) << 2) | (qualityofservice->traffichandlingpriority & 0x3); encoded++; *(buffer + encoded) = qualityofservice->guaranteedbitrateuplink; encoded++; *(buffer + encoded) = qualityofservice->guaranteedbitratedownlink; encoded++; *(buffer + encoded) = 0x00 | ((qualityofservice->signalingindication & 0x1) << 4) | (qualityofservice->sourcestatisticsdescriptor & 0xf); encoded++; *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); return encoded; }
int encode_imeisv_request(ImeisvRequest *imeisvrequest, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t encoded = 0; /* Checking length and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, IMEISV_REQUEST_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_imeisv_request_xml(imeisvrequest, iei); #endif *(buffer + encoded) = 0x00 | (iei & 0xf0) | (*imeisvrequest & 0x7); encoded++; return encoded; }
int encode_ue_radio_capability_information_update_needed(UeRadioCapabilityInformationUpdateNeeded *ueradiocapabilityinformationupdateneeded, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t encoded = 0; /* Checking length and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_ue_radio_capability_information_update_needed_xml(ueradiocapabilityinformationupdateneeded, iei); #endif *(buffer + encoded) = 0x00 | (iei & 0xf0) | (*ueradiocapabilityinformationupdateneeded & 0x1); encoded++; return encoded; }
int encode_identity_type_2(IdentityType2 *identitytype2, uint8_t iei, uint8_t *buffer, uint32_t len) { uint8_t encoded = 0; /* Checking length and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, IDENTITY_TYPE_2_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) dump_identity_type_2_xml(identitytype2, iei); #endif *(buffer + encoded) = 0x00 | (iei & 0xf0) | (*identitytype2 & 0x7); encoded++; return encoded; }