implement pdusession establishment request
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
/*! \file FGSUplinkNasTransport.c
|
||||
|
||||
\brief uplink nas transport procedures
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "FGSUplinkNasTransport.h"
|
||||
#include "TLVEncoder.h"
|
||||
|
||||
int encode_fgs_payload_container(FGSPayloadContainer *paycontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
uint32_t encoded = 0;
|
||||
int encode_result;
|
||||
|
||||
if (iei > 0) {
|
||||
*buffer = iei;
|
||||
encoded++;
|
||||
}
|
||||
|
||||
encoded += 2;
|
||||
|
||||
if ((encode_result = encode_octet_string(&paycontainer->payloadcontainercontents, buffer + encoded, len - encoded)) < 0) {
|
||||
return encode_result;
|
||||
} else {
|
||||
encoded += encode_result;
|
||||
}
|
||||
if(iei > 0){
|
||||
*(uint16_t*) (buffer+1) = htons(encoded - 3);
|
||||
} else {
|
||||
*(uint16_t*) (buffer) = htons(encoded - 2);
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
int encode_nssai(OctetString *nssai, uint8_t iei, uint8_t *buffer)
|
||||
{
|
||||
uint32_t encoded = 0;
|
||||
int encode_result;
|
||||
|
||||
if (iei > 0) {
|
||||
*buffer = iei;
|
||||
encoded++;
|
||||
}
|
||||
|
||||
*(buffer + encoded) = nssai->length;
|
||||
encoded++;
|
||||
|
||||
|
||||
if ((encode_result = encode_octet_string(nssai, buffer + encoded, nssai->length)) < 0) {
|
||||
return encode_result;
|
||||
} else {
|
||||
encoded += encode_result;
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
int encode_dnn(OctetString *dnn, uint8_t iei, uint8_t *buffer)
|
||||
{
|
||||
uint32_t encoded = 0;
|
||||
int encode_result;
|
||||
|
||||
if (iei > 0) {
|
||||
*buffer = iei;
|
||||
encoded++;
|
||||
}
|
||||
|
||||
*(buffer + encoded) = dnn->length;
|
||||
encoded++;
|
||||
|
||||
if ((encode_result = encode_octet_string(dnn, buffer + encoded, dnn->length)) < 0) {
|
||||
return encode_result;
|
||||
} else {
|
||||
encoded += encode_result;
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
int encode_fgs_uplink_nas_transport(fgs_uplink_nas_transport_msg *fgs_up_nas_transport, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int encoded = 0;
|
||||
int encode_result = 0;
|
||||
|
||||
*(buffer + encoded) = (fgs_up_nas_transport->payloadcontainertype.iei << 4) | (fgs_up_nas_transport->payloadcontainertype.type &0xf);
|
||||
encoded++;
|
||||
|
||||
if ((encode_result = encode_fgs_payload_container(&fgs_up_nas_transport->fgspayloadcontainer,
|
||||
0, buffer +encoded, len - encoded)) < 0) {
|
||||
return encode_result;
|
||||
} else {
|
||||
encoded += encode_result;
|
||||
}
|
||||
|
||||
*(buffer + encoded) = 0x12;
|
||||
encoded++;
|
||||
|
||||
IES_ENCODE_U8(buffer, encoded, fgs_up_nas_transport->pdusessionid);
|
||||
|
||||
// set request type
|
||||
*(buffer + encoded) = (0x8<<4)|(fgs_up_nas_transport->requesttype &0x7);
|
||||
encoded++;
|
||||
|
||||
if ((encode_result = encode_nssai(&fgs_up_nas_transport->snssai, 0x22, buffer +encoded)) < 0) {
|
||||
return encode_result;
|
||||
} else {
|
||||
encoded += encode_result;
|
||||
}
|
||||
|
||||
if ((encode_result = encode_dnn(&fgs_up_nas_transport->dnn, 0x25, buffer +encoded)) < 0) {
|
||||
return encode_result;
|
||||
} else {
|
||||
encoded += encode_result;
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*! \file FGSUplinkNasTransport.h
|
||||
|
||||
\brief uplink nas transport procedures
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ExtendedProtocolDiscriminator.h"
|
||||
#include "SecurityHeaderType.h"
|
||||
#include "SpareHalfOctet.h"
|
||||
#include "MessageType.h"
|
||||
|
||||
#ifndef FGS_UPLINK_NAS_TRANSPORT_H_
|
||||
#define FGS_UPLINK_NAS_TRANSPORT_H_
|
||||
|
||||
/*
|
||||
* Message name: uplink nas transpaort
|
||||
* Description: The UL NAS TRANSPORT message transports message payload and associated information to the AMF. See table 8.2.10.1.1.
|
||||
* Significance: dual
|
||||
* Direction: UE to network
|
||||
*/
|
||||
|
||||
typedef struct PayloadContainerType_tag{
|
||||
uint8_t iei:4;
|
||||
uint8_t type:4;
|
||||
}PayloadContainerType;
|
||||
typedef struct FGSPayloadContainer_tag {
|
||||
OctetString payloadcontainercontents;
|
||||
} FGSPayloadContainer;
|
||||
|
||||
typedef struct fgs_uplink_nas_transport_msg_tag {
|
||||
/* Mandatory fields */
|
||||
ExtendedProtocolDiscriminator protocoldiscriminator;
|
||||
SecurityHeaderType securityheadertype:4;
|
||||
SpareHalfOctet sparehalfoctet:4;
|
||||
MessageType messagetype;
|
||||
PayloadContainerType payloadcontainertype;
|
||||
FGSPayloadContainer fgspayloadcontainer;
|
||||
/* Optional fields */
|
||||
uint16_t pdusessionid;
|
||||
uint8_t requesttype;
|
||||
OctetString snssai;
|
||||
OctetString dnn;
|
||||
} fgs_uplink_nas_transport_msg;
|
||||
|
||||
int encode_fgs_uplink_nas_transport(fgs_uplink_nas_transport_msg *fgs_security_mode_comp, uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* ! defined(FGS_UPLINK_NAS_TRANSPORT_H_) */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user