Commit 6e294e27 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'clean_up_nas' into 'develop'

Clean up nas

See merge request oai/cn5g/oai-cn5g-smf!22
parents f8300c31 45699325
This diff is collapsed.
/*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2015, and is covered by the BSD open source
* license and the GPL. Refer to the accompanying documentation for details
* on usage and license.
*/
/*
* bstraux.h
*
* This file is not a necessary part of the core bstring library itself, but
* is just an auxilliary module which includes miscellaneous or trivial
* functions.
*/
#ifndef BSTRAUX_INCLUDE
#define BSTRAUX_INCLUDE
#include <time.h>
#include "bstrlib.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Safety mechanisms */
#define bstrDeclare(b) bstring (b) = NULL;
#define bstrFree(b) {if ((b) != NULL && (b)->slen >= 0 && (b)->mlen >= (b)->slen) { bdestroy (b); (b) = NULL; }}
/* Backward compatibilty with previous versions of Bstrlib */
#if !defined(BSTRLIB_REDUCE_NAMESPACE_POLLUTION)
#define bAssign(a,b) ((bassign)((a), (b)))
#define bSubs(b,pos,len,a,c) ((breplace)((b),(pos),(len),(a),(unsigned char)(c)))
#define bStrchr(b,c) ((bstrchr)((b), (c)))
#define bStrchrFast(b,c) ((bstrchr)((b), (c)))
#define bCatCstr(b,s) ((bcatcstr)((b), (s)))
#define bCatBlk(b,s,len) ((bcatblk)((b),(s),(len)))
#define bCatStatic(b,s) bcatStatic(b,s)
#define bTrunc(b,n) ((btrunc)((b), (n)))
#define bReplaceAll(b,find,repl,pos) ((bfindreplace)((b),(find),(repl),(pos)))
#define bUppercase(b) ((btoupper)(b))
#define bLowercase(b) ((btolower)(b))
#define bCaselessCmp(a,b) ((bstricmp)((a), (b)))
#define bCaselessNCmp(a,b,n) ((bstrnicmp)((a), (b), (n)))
#define bBase64Decode(b) (bBase64DecodeEx ((b), NULL))
#define bUuDecode(b) (bUuDecodeEx ((b), NULL))
#endif
/* Unusual functions */
extern struct bStream * bsFromBstr (const_bstring b);
extern bstring bTail (bstring b, int n);
extern bstring bHead (bstring b, int n);
extern int bSetCstrChar (bstring a, int pos, char c);
extern int bSetChar (bstring b, int pos, char c);
extern int bFill (bstring a, char c, int len);
extern int bReplicate (bstring b, int n);
extern int bReverse (bstring b);
extern int bInsertChrs (bstring b, int pos, int len, unsigned char c, unsigned char fill);
extern bstring bStrfTime (const char * fmt, const struct tm * timeptr);
#define bAscTime(t) (bStrfTime ("%c\n", (t)))
#define bCTime(t) ((t) ? bAscTime (localtime (t)) : NULL)
/* Spacing formatting */
extern int bJustifyLeft (bstring b, int space);
extern int bJustifyRight (bstring b, int width, int space);
extern int bJustifyMargin (bstring b, int width, int space);
extern int bJustifyCenter (bstring b, int width, int space);
/* Esoteric standards specific functions */
extern char * bStr2NetStr (const_bstring b);
extern bstring bNetStr2Bstr (const char * buf);
extern bstring bBase64Encode (const_bstring b);
extern bstring bBase64DecodeEx (const_bstring b, int * boolTruncError);
extern struct bStream * bsUuDecode (struct bStream * sInp, int * badlines);
extern bstring bUuDecodeEx (const_bstring src, int * badlines);
extern bstring bUuEncode (const_bstring src);
extern bstring bYEncode (const_bstring src);
extern bstring bYDecode (const_bstring src);
extern int bSGMLEncode (bstring b);
/* Writable stream */
typedef int (* bNwrite) (const void * buf, size_t elsize, size_t nelem, void * parm);
struct bwriteStream * bwsOpen (bNwrite writeFn, void * parm);
int bwsWriteBstr (struct bwriteStream * stream, const_bstring b);
int bwsWriteBlk (struct bwriteStream * stream, void * blk, int len);
int bwsWriteFlush (struct bwriteStream * stream);
int bwsIsEOF (const struct bwriteStream * stream);
int bwsBuffLength (struct bwriteStream * stream, int sz);
void * bwsClose (struct bwriteStream * stream);
/* Security functions */
#define bSecureDestroy(b) { \
bstring bstr__tmp = (b); \
if (bstr__tmp && bstr__tmp->mlen > 0 && bstr__tmp->data) { \
(void) memset (bstr__tmp->data, 0, (size_t) bstr__tmp->mlen); \
bdestroy (bstr__tmp); \
} \
}
#define bSecureWriteProtect(t) { \
if ((t).mlen >= 0) { \
if ((t).mlen > (t).slen)) { \
(void) memset ((t).data + (t).slen, 0, (size_t) (t).mlen - (t).slen); \
} \
(t).mlen = -1; \
} \
}
extern bstring bSecureInput (int maxlen, int termchar,
bNgetc vgetchar, void * vgcCtx);
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2015, and is covered by the BSD open source
* license. Refer to the accompanying documentation for details on usage and
* license.
*/
/*
* testaux.c
*
* This file is the C unit test for the bstraux module of Bstrlib.
*/
#include <stdio.h>
#include "bstrlib.h"
#include "bstraux.h"
static int tWrite (const void * buf, size_t elsize, size_t nelem, void * parm) {
bstring b = (bstring) parm;
size_t i;
if (NULL == b || NULL == buf || 0 == elsize || 0 == nelem)
return -__LINE__;
for (i=0; i < nelem; i++) {
if (0 > bcatblk (b, buf, elsize)) break;
buf = (const void *) (elsize + (const char *) buf);
}
return (int) i;
}
int test0 (void) {
struct bwriteStream * ws;
bstring s;
int ret = 0;
printf ("TEST: struct bwriteStream functions.\n");
ws = bwsOpen ((bNwrite) tWrite, (s = bfromcstr ("")));
bwsBuffLength (ws, 8);
ret += 8 != bwsBuffLength (ws, 0);
bwsWriteBlk (ws, bsStaticBlkParms ("Hello "));
ret += 0 == biseqcstr (s, "");
bwsWriteBlk (ws, bsStaticBlkParms ("World\n"));
ret += 0 == biseqcstr (s, "Hello Wo");
ret += s != bwsClose (ws);
ret += 0 == biseqcstr (s, "Hello World\n");
printf ("\t# failures: %d\n", ret);
return ret;
}
int test1 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b, c, d;
int ret = 0;
printf ("TEST: bTail and bHead functions.\n");
b = bTail (&t, 5);
c = bHead (&t, 5);
ret += 0 >= biseqcstr (b, "world");
ret += 0 >= biseqcstr (c, "Hello");
bdestroy (b);
bdestroy (c);
b = bTail (&t, 0);
c = bHead (&t, 0);
ret += 0 >= biseqcstr (b, "");
ret += 0 >= biseqcstr (c, "");
bdestroy (b);
bdestroy (c);
d = bstrcpy (&t);
b = bTail (d, 5);
c = bHead (d, 5);
ret += 0 >= biseqcstr (b, "world");
ret += 0 >= biseqcstr (c, "Hello");
bdestroy (b);
bdestroy (c);
bdestroy (d);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test2 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
int ret = 0, reto;
printf ("TEST: bSetChar function.\n");
ret += 0 <= bSetChar (&t, 4, ',');
ret += 0 > bSetChar (b = bstrcpy (&t), 4, ',');
ret += 0 >= biseqcstr (b, "Hell, world");
ret += 0 <= bSetChar (b, -1, 'x');
b->slen = 2;
ret += 0 > bSetChar (b, 1, 'i');
ret += 0 >= biseqcstr (b, "Hi");
ret += 0 > bSetChar (b, 2, 's');
ret += 0 >= biseqcstr (b, "His");
ret += 0 > bSetChar (b, 1, '\0');
ret += blength (b) != 3;
ret += bchare (b, 0, '?') != 'H';
ret += bchare (b, 1, '?') != '\0';
ret += bchare (b, 2, '?') != 's';
bdestroy (b);
printf ("\t# failures: %d\n", ret);
reto = ret;
ret = 0;
printf ("TEST: bSetCstrChar function.\n");
ret += 0 <= bSetCstrChar (&t, 4, ',');
ret += 0 > bSetCstrChar (b = bstrcpy (&t), 4, ',');
ret += 0 >= biseqcstr (b, "Hell, world");
ret += 0 <= bSetCstrChar (b, -1, 'x');
b->slen = 2;
ret += 0 > bSetCstrChar (b, 1, 'i');
ret += 0 >= biseqcstr (b, "Hi");
ret += 0 > bSetCstrChar (b, 2, 's');
ret += 0 >= biseqcstr (b, "His");
ret += 0 > bSetCstrChar (b, 1, '\0');
ret += blength (b) != 1;
ret += bchare (b, 0, '?') != 'H';
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return reto + ret;
}
int test3 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
int ret = 0;
printf ("TEST: bFill function.\n");
ret += 0 <= bFill (&t, 'x', 7);
ret += 0 > bFill (b = bstrcpy (&t), 'x', 7);
ret += 0 >= biseqcstr (b, "xxxxxxx");
ret += 0 <= bFill (b, 'x', -1);
ret += 0 > bFill (b, 'x', 0);
ret += 0 >= biseqcstr (b, "");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test4 (void) {
struct tagbstring t = bsStatic ("foo");
bstring b;
int ret = 0;
printf ("TEST: bReplicate function.\n");
ret += 0 <= bReplicate (&t, 4);
ret += 0 <= bReplicate (b = bstrcpy (&t), -1);
ret += 0 > bReplicate (b, 4);
ret += 0 >= biseqcstr (b, "foofoofoofoo");
ret += 0 > bReplicate (b, 0);
ret += 0 >= biseqcstr (b, "");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test5 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
int ret = 0;
printf ("TEST: bReverse function.\n");
ret += 0 <= bReverse (&t);
ret += 0 > bReverse (b = bstrcpy (&t));
ret += 0 >= biseqcstr (b, "dlrow olleH");
b->slen = 0;
ret += 0 > bReverse (b);
ret += 0 >= biseqcstr (b, "");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test6 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
int ret = 0;
printf ("TEST: bInsertChrs function.\n");
ret += 0 <= bInsertChrs (&t, 6, 4, 'x', '?');
ret += 0 > bInsertChrs (b = bstrcpy (&t), 6, 4, 'x', '?');
ret += 0 >= biseqcstr (b, "Hello xxxxworld");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test7 (void) {
struct tagbstring t = bsStatic (" i am ");
bstring b;
int ret = 0;
printf ("TEST: bJustify functions.\n");
ret += 0 <= bJustifyLeft (&t, ' ');
ret += 0 <= bJustifyRight (&t, 8, ' ');
ret += 0 <= bJustifyMargin (&t, 8, ' ');
ret += 0 <= bJustifyCenter (&t, 8, ' ');
ret += 0 > bJustifyLeft (b = bstrcpy (&t), ' ');
ret += 0 >= biseqcstr (b, "i am");
ret += 0 > bJustifyRight (b, 8, ' ');
ret += 0 >= biseqcstr (b, " i am");
ret += 0 > bJustifyMargin (b, 8, ' ');
ret += 0 >= biseqcstr (b, "i am");
ret += 0 > bJustifyCenter (b, 8, ' ');
ret += 0 >= biseqcstr (b, " i am");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test8 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
char * c;
int ret = 0;
printf ("TEST: NetStr functions.\n");
c = bStr2NetStr (&t);
ret += 0 != strcmp (c, "11:Hello world,");
b = bNetStr2Bstr (c);
ret += 0 >= biseq (b, &t);
bdestroy (b);
bcstrfree (c);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test9 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b, c;
int err, ret = 0;
printf ("TEST: Base 64 codec.\n");
b = bBase64Encode (&t);
ret += 0 >= biseqcstr (b, "SGVsbG8gd29ybGQ=");
c = bBase64DecodeEx (b, &err);
ret += 0 != err;
ret += 0 >= biseq (c, &t);
bdestroy (b);
bdestroy (c);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test10 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b, c;
int err, ret = 0;
printf ("TEST: UU codec.\n");
b = bUuEncode (&t);
ret += 0 >= biseqcstr (b, "+2&5L;&\\@=V]R;&0`\r\n");
c = bUuDecodeEx (b, &err);
ret += 0 != err;
ret += 0 >= biseq (c, &t);
bdestroy (b);
bdestroy (c);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test11 (void) {
struct tagbstring t = bsStatic ("Hello world");
unsigned char Ytstr[] = {0x72, 0x8f, 0x96, 0x96, 0x99, 0x4a, 0xa1, 0x99, 0x9c, 0x96, 0x8e};
bstring b, c;
int ret = 0;
printf ("TEST: Y codec.\n");
b = bYEncode (&t);
ret += 11 != b->slen;
ret += 0 >= bisstemeqblk (b, Ytstr, 11);
c = bYDecode (b);
ret += 0 >= biseq (c, &t);
bdestroy (b);
bdestroy (c);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test12 (void) {
struct tagbstring t = bsStatic ("Hello world");
struct bStream * s;
bstring b;
int ret = 0;
printf ("TEST: bsFromBstr.\n");
ret = bsread (b = bfromcstr (""), s = bsFromBstr (&t), 6);
ret += 1 != biseqcstr (b, "Hello ");
if (b) b->slen = 0;
ret = bsread (b, s, 6);
ret += 1 != biseqcstr (b, "world");
bdestroy (b);
bsclose (s);
printf ("\t# failures: %d\n", ret);
return ret;
}
struct vfgetc {
int ofs;
bstring base;
};
static int test13_fgetc (void * ctx) {
struct vfgetc * vctx = (struct vfgetc *) ctx;
int c;
if (NULL == vctx || NULL == vctx->base) return EOF;
if (vctx->ofs >= blength (vctx->base)) return EOF;
c = bchare (vctx->base, vctx->ofs, EOF);
vctx->ofs++;
return c;
}
int test13 (void) {
struct tagbstring t0 = bsStatic ("Random String, long enough to cause to reallocing");
struct vfgetc vctx;
bstring b;
int ret = 0;
int i;
printf ("TEST: bSecureInput, bSecureDestroy.\n");
for (i=0; i < 1000; i++) {
unsigned char * h;
vctx.ofs = 0;
vctx.base = &t0;
b = bSecureInput (INT_MAX, '\n', (bNgetc) test13_fgetc, &vctx);
ret += 1 != biseq (b, &t0);
h = b->data;
bSecureDestroy (b);
/* WARNING! Technically undefined code follows (h has been freed): */
ret += (0 == memcmp (h, t0.data, t0.slen));
if (ret) break;
}
printf ("\t# failures: %d\n", ret);
return ret;
}
int test14_aux(bstring b, const char* chkVal) {
int ret = 0;
ret += 0 != bSGMLEncode (b);
ret += 1 != biseqcstr (b, chkVal);
return ret;
}
int test14 (void) {
bstring b;
int ret = 0;
printf ("TEST: bSGMLEncode.\n");
ret += test14_aux (b = bfromStatic ("<\"Hello, you, me, & world\">"), "&lt;&quot;Hello, you, me, &amp; world&quot;&gt;");
printf ("\t# failures: %d\n", ret);
return ret;
}
/*
int main () {
int ret = 0;
printf ("Direct case testing of bstraux functions\n");
ret += test0 ();
ret += test1 ();
ret += test2 ();
ret += test3 ();
ret += test4 ();
ret += test5 ();
ret += test6 ();
ret += test7 ();
ret += test8 ();
ret += test9 ();
ret += test10 ();
ret += test11 ();
ret += test12 ();
ret += test13 ();
ret += test14 ();
printf ("# test failures: %d\n", ret);
return 0;
}
*/
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
......@@ -6,59 +27,50 @@
#include "TLVDecoder.h"
#include "ABBA.h"
int encode_abba ( ABBA abba, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ABBA_MINIMUM_LENGTH , len);
int encode_abba(ABBA abba, uint8_t iei, uint8_t *buffer, uint32_t len) {
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ABBA_MINIMUM_LENGTH, len);
if( iei >0 )
{
*buffer=iei;
encoded++;
}
if (iei > 0) {
*buffer = iei;
encoded++;
}
// *buffer = iei;
// encoded++;
lenPtr = (buffer + encoded);
encoded++;
lenPtr = (buffer + encoded);
encoded++;
if ((encode_result = encode_bstring(abba, buffer + encoded, len - encoded)) < 0) //加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
if ((encode_result = encode_bstring (abba, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
}
int decode_abba ( ABBA * abba, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
int decode_abba(ABBA *abba, uint8_t iei, uint8_t *buffer, uint32_t len) {
int decoded = 0;
uint8_t ielen = 0;
int decode_result;
ielen = *(buffer + decoded);
if (iei > 0) {
CHECK_IEI_DECODER(iei, *buffer);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
}
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER(len - decoded, ielen);
if((decode_result = decode_bstring (abba, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
return decoded;
if ((decode_result = decode_bstring(abba, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
return decoded;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef ABBA_H_
#define ABBA_H_
#include <stdint.h>
#include "bstrlib.h"
......@@ -5,6 +29,7 @@
typedef bstring ABBA;
int encode_abba ( ABBA abba, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_abba ( ABBA * abba, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int encode_abba(ABBA abba, uint8_t iei, uint8_t *buffer, uint32_t len);
int decode_abba(ABBA *abba, uint8_t iei, uint8_t *buffer, uint32_t len);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
......@@ -6,59 +27,56 @@
#include "TLVDecoder.h"
#include "Additional5GSecurityInformation.h"
int encode_additional_5g_security_information ( Additional5GSecurityInformation additional5gsecurityinformation, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
uint8_t bitStream = 0x0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ADDITIONAL_5G_SECURITY_INFORMATION_MINIMUM_LENGTH , len);
if( iei >0 ){
*buffer=iei;
encoded++;
}
int encode_additional_5g_security_information(Additional5GSecurityInformation additional5gsecurityinformation, uint8_t iei, uint8_t *buffer, uint32_t len) {
uint8_t *lenPtr;
uint32_t encoded = 0;
uint8_t bitStream = 0x0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ADDITIONAL_5G_SECURITY_INFORMATION_MINIMUM_LENGTH, len);
lenPtr = (buffer + encoded);
if (iei > 0) {
*buffer = iei;
encoded++;
}
if(additional5gsecurityinformation.rinmr)
bitStream |= 0x02;
if(additional5gsecurityinformation.hdp)
bitStream |= 0x01;
lenPtr = (buffer + encoded);
encoded++;
ENCODE_U8(buffer+encoded,bitStream,encoded);
if (additional5gsecurityinformation.rinmr)
bitStream |= 0x02;
if (additional5gsecurityinformation.hdp)
bitStream |= 0x01;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
}
ENCODE_U8(buffer + encoded, bitStream, encoded);
int decode_additional_5g_security_information ( Additional5GSecurityInformation * additional5gsecurityinformation, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t ielen=0;
uint8_t bitStream = 0x0;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
}
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
int decode_additional_5g_security_information(Additional5GSecurityInformation *additional5gsecurityinformation, uint8_t iei, uint8_t *buffer, uint32_t len) {
int decoded = 0;
uint8_t ielen = 0;
uint8_t bitStream = 0x0;
ielen = *(buffer + decoded);
if (iei > 0) {
CHECK_IEI_DECODER(iei, *buffer);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
}
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER(len - decoded, ielen);
DECODE_U8(buffer+decoded,bitStream,decoded);
if(bitStream&0x02)
additional5gsecurityinformation->rinmr = true;
else
additional5gsecurityinformation->rinmr = false;
DECODE_U8(buffer + decoded, bitStream, decoded);
if (bitStream & 0x02)
additional5gsecurityinformation->rinmr = true;
else
additional5gsecurityinformation->rinmr = false;
if(bitStream&0x01)
additional5gsecurityinformation->hdp = true;
else
additional5gsecurityinformation->rinmr = false;
if (bitStream & 0x01)
additional5gsecurityinformation->hdp = true;
else
additional5gsecurityinformation->rinmr = false;
return decoded;
return decoded;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _ADDITIONAL_5G_SECURITY_INFORMATION_H_
#define _ADDITIONAL_5G_SECURITY_INFORMATION_H_
......@@ -14,12 +35,12 @@
#define RETRANSMISSION_OF_THE_INITIAL_NAS_MESSAGE_NOT_REQUESTED 0
#define RETRANSMISSION_OF_THE_INITIAL_NAS_MESSAGE_REQUESTED 1
typedef struct{
typedef struct {
bool hdp;
bool rinmr;
} Additional5GSecurityInformation;
int encode_additional_5g_security_information ( Additional5GSecurityInformation additional5gsecurityinformation, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_additional_5g_security_information ( Additional5GSecurityInformation * additional5gsecurityinformation, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int encode_additional_5g_security_information(Additional5GSecurityInformation additional5gsecurityinformation, uint8_t iei, uint8_t *buffer, uint32_t len);
int decode_additional_5g_security_information(Additional5GSecurityInformation *additional5gsecurityinformation, uint8_t iei, uint8_t *buffer, uint32_t len);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
......@@ -6,58 +27,47 @@
#include "TLVDecoder.h"
#include "AdditionalInformation.h"
int encode_additional_information ( AdditionalInformation additionalinformation, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ADDITIONAL_INFORMATION_MINIMUM_LENGTH , len);
if( iei >0 )
{
*buffer=iei;
encoded++;
}
int encode_additional_information(AdditionalInformation additionalinformation, uint8_t iei, uint8_t *buffer, uint32_t len) {
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ADDITIONAL_INFORMATION_MINIMUM_LENGTH, len);
lenPtr = (buffer + encoded);
if (iei > 0) {
*buffer = iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
if ((encode_result = encode_bstring(additionalinformation, buffer + encoded, len - encoded)) < 0) //加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
if ((encode_result = encode_bstring (additionalinformation, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
}
int decode_additional_information ( AdditionalInformation * additionalinformation, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
int decode_additional_information(AdditionalInformation *additionalinformation, uint8_t iei, uint8_t *buffer, uint32_t len) {
int decoded = 0;
uint8_t ielen = 0;
int decode_result;
ielen = *(buffer + decoded);
if (iei > 0) {
CHECK_IEI_DECODER(iei, *buffer);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
}
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER(len - decoded, ielen);
if((decode_result = decode_bstring (additionalinformation, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
return decoded;
if ((decode_result = decode_bstring(additionalinformation, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
return decoded;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef ADDITIONAL_INFORMATION_H_
#define ADDITIONAL_INFORMATION_H_
#include <stdint.h>
#include "bstrlib.h"
......@@ -6,6 +30,7 @@
typedef bstring AdditionalInformation;
int encode_additional_information ( AdditionalInformation additionalinformation, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_additional_information ( AdditionalInformation * additionalinformation, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int encode_additional_information(AdditionalInformation additionalinformation, uint8_t iei, uint8_t *buffer, uint32_t len);
int decode_additional_information(AdditionalInformation *additionalinformation, uint8_t iei, uint8_t *buffer, uint32_t len);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
......@@ -6,43 +27,40 @@
#include "TLVDecoder.h"
#include "AllowedPDUSessionStatus.h"
int encode_allowed_pdu_session_status ( AllowedPDUSessionStatus allowedpdusessionstatus, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ALLOWED_PDU_SESSION_STATUS_MINIMUM_LENGTH , len);
if( iei >0 ){
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
int encode_allowed_pdu_session_status(AllowedPDUSessionStatus allowedpdusessionstatus, uint8_t iei, uint8_t *buffer, uint32_t len) {
uint8_t *lenPtr;
uint32_t encoded = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ALLOWED_PDU_SESSION_STATUS_MINIMUM_LENGTH, len);
if (iei > 0) {
*buffer = iei;
encoded++;
}
ENCODE_U16(buffer+encoded, allowedpdusessionstatus, encoded);
lenPtr = (buffer + encoded);
encoded++;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
}
ENCODE_U16(buffer + encoded, allowedpdusessionstatus, encoded);
int decode_allowed_pdu_session_status ( AllowedPDUSessionStatus * allowedpdusessionstatus, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t ielen=0;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
}
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
int decode_allowed_pdu_session_status(AllowedPDUSessionStatus *allowedpdusessionstatus, uint8_t iei, uint8_t *buffer, uint32_t len) {
int decoded = 0;
uint8_t ielen = 0;
ielen = *(buffer + decoded);
if (iei > 0) {
CHECK_IEI_DECODER(iei, *buffer);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
}
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER(len - decoded, ielen);
DECODE_U16(buffer+decoded, *allowedpdusessionstatus,decoded);
DECODE_U16(buffer + decoded, *allowedpdusessionstatus, decoded);
return decoded;
return decoded;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef ALLOWED_PDU_SESSION_STATUS_H_
#define ALLOWED_PDU_SESSION_STATUS_H_
#include <stdint.h>
#include "bstrlib.h"
......@@ -6,6 +30,7 @@
typedef uint8_t AllowedPDUSessionStatus;
int encode_allowed_pdu_session_status ( AllowedPDUSessionStatus allowedpdusessionstatus, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_allowed_pdu_session_status ( AllowedPDUSessionStatus * allowedpdusessionstatus, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int encode_allowed_pdu_session_status(AllowedPDUSessionStatus allowedpdusessionstatus, uint8_t iei, uint8_t *buffer, uint32_t len);
int decode_allowed_pdu_session_status(AllowedPDUSessionStatus *allowedpdusessionstatus, uint8_t iei, uint8_t *buffer, uint32_t len);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
......@@ -6,70 +27,56 @@
#include "TLVDecoder.h"
#include "AllowedSSCMode.h"
int encode_allowed_ssc_mode ( AllowedSSCMode allowedsscmode, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int encode_allowed_ssc_mode(AllowedSSCMode allowedsscmode, uint8_t iei, uint8_t *buffer, uint32_t len) {
uint32_t encoded = 0;
uint8_t bitStream = 0x00;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ALLOWED_SSC_MODE_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ALLOWED_SSC_MODE_MINIMUM_LENGTH, len);
if(iei > 0){
if (iei > 0) {
bitStream |= (iei & 0xf0);
}
if(allowedsscmode.is_ssc3_allowed)
{
if (allowedsscmode.is_ssc3_allowed) {
bitStream |= 0x04;
}
if(allowedsscmode.is_ssc2_allowed)
{
if (allowedsscmode.is_ssc2_allowed) {
bitStream |= 0x02;
}
if(allowedsscmode.is_ssc1_allowed)
{
if (allowedsscmode.is_ssc1_allowed) {
bitStream |= 0x01;
}
ENCODE_U8(buffer+encoded,bitStream,encoded);
ENCODE_U8(buffer + encoded, bitStream, encoded);
return encoded;
}
int decode_allowed_ssc_mode ( AllowedSSCMode * allowedsscmode, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
int decode_allowed_ssc_mode(AllowedSSCMode *allowedsscmode, uint8_t iei, uint8_t *buffer, uint32_t len) {
int decoded = 0;
uint8_t bitStream = 0x00;
DECODE_U8(buffer+decoded,bitStream,decoded);
DECODE_U8(buffer + decoded, bitStream, decoded);
if(iei != (bitStream&0xf0)){
if (iei != (bitStream & 0xf0)) {
return -1;
}
if(iei > 0){
if (iei > 0) {
bitStream = (bitStream & 0x07);
}
if(bitStream & 0x01)
{
if (bitStream & 0x01) {
allowedsscmode->is_ssc1_allowed = true;
}
else
{
} else {
allowedsscmode->is_ssc1_allowed = false;
}
if(bitStream & 0x02)
{
if (bitStream & 0x02) {
allowedsscmode->is_ssc2_allowed = true;
}
else
{
} else {
allowedsscmode->is_ssc2_allowed = false;
}
if(bitStream & 0x04)
{
if (bitStream & 0x04) {
allowedsscmode->is_ssc3_allowed = true;
}
else
{
} else {
allowedsscmode->is_ssc3_allowed = false;
}
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _ALLOWEDSSCMODE_H_
#define _ALLOWEDSSCMODE_H_
......@@ -16,14 +37,13 @@
#define SSC_MODE3_ALLOWED 1
//typedef bstring AllowedSSCMode;
typedef struct{
bool is_ssc1_allowed;
bool is_ssc2_allowed;
bool is_ssc3_allowed;
}AllowedSSCMode;
typedef struct {
bool is_ssc1_allowed;
bool is_ssc2_allowed;
bool is_ssc3_allowed;
} AllowedSSCMode;
int encode_allowed_ssc_mode ( AllowedSSCMode allowedsscmode, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_allowed_ssc_mode ( AllowedSSCMode * allowedsscmode, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int encode_allowed_ssc_mode(AllowedSSCMode allowedsscmode, uint8_t iei, uint8_t *buffer, uint32_t len);
int decode_allowed_ssc_mode(AllowedSSCMode *allowedsscmode, uint8_t iei, uint8_t *buffer, uint32_t len);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
......@@ -6,46 +27,43 @@
#include "TLVDecoder.h"
#include "AlwaysonPDUSessionIndication.h"
int encode_alwayson_pdu_session_indication ( AlwaysonPDUSessionIndication alwaysonpdusessionindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint32_t encoded = 0;
uint8_t bitStream = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ALWAYSON_PDU_SESSION_INDICATION_MINIMUM_LENGTH , len);
if(iei > 0){
bitStream = iei & 0xf0;
}
if(alwaysonpdusessionindication.apsi_indication)
bitStream |= 0x01;
ENCODE_U8(buffer+encoded,bitStream,encoded);
return encoded;
int encode_alwayson_pdu_session_indication(AlwaysonPDUSessionIndication alwaysonpdusessionindication, uint8_t iei, uint8_t *buffer, uint32_t len) {
uint32_t encoded = 0;
uint8_t bitStream = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ALWAYSON_PDU_SESSION_INDICATION_MINIMUM_LENGTH, len);
if (iei > 0) {
bitStream = iei & 0xf0;
}
if (alwaysonpdusessionindication.apsi_indication)
bitStream |= 0x01;
ENCODE_U8(buffer + encoded, bitStream, encoded);
return encoded;
}
int decode_alwayson_pdu_session_indication ( AlwaysonPDUSessionIndication * alwaysonpdusessionindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t bitStream = 0;
DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != (bitStream&0xf0)){
return -1;
}
if(iei > 0){
bitStream = bitStream & 0x01;
}
if(bitStream)
alwaysonpdusessionindication->apsi_indication = true;
else
alwaysonpdusessionindication->apsi_indication = false;
return decoded;
int decode_alwayson_pdu_session_indication(AlwaysonPDUSessionIndication *alwaysonpdusessionindication, uint8_t iei, uint8_t *buffer, uint32_t len) {
int decoded = 0;
uint8_t bitStream = 0;
DECODE_U8(buffer + decoded, bitStream, decoded);
if (iei != (bitStream & 0xf0)) {
return -1;
}
if (iei > 0) {
bitStream = bitStream & 0x01;
}
if (bitStream)
alwaysonpdusessionindication->apsi_indication = true;
else
alwaysonpdusessionindication->apsi_indication = false;
return decoded;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _ALWAYSONPDUSESSIONINDICATION_H_
#define _ALWAYSONPDUSESSIONINDICATION_H_
......@@ -11,12 +32,11 @@
#define ALWAYSON_PDU_SESSION_NOT_ALLOWED 0
#define ALWAYSON_PDU_SESSION_REQUIRED 1
typedef struct{
bool apsi_indication;
}AlwaysonPDUSessionIndication;
typedef struct {
bool apsi_indication;
} AlwaysonPDUSessionIndication;
int encode_alwayson_pdu_session_indication ( AlwaysonPDUSessionIndication alwaysonpdusessionindication, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_alwayson_pdu_session_indication ( AlwaysonPDUSessionIndication * alwaysonpdusessionindication, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int encode_alwayson_pdu_session_indication(AlwaysonPDUSessionIndication alwaysonpdusessionindication, uint8_t iei, uint8_t *buffer, uint32_t len);
int decode_alwayson_pdu_session_indication(AlwaysonPDUSessionIndication *alwaysonpdusessionindication, uint8_t iei, uint8_t *buffer, uint32_t len);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
......@@ -6,41 +27,39 @@
#include "TLVDecoder.h"
#include "AlwaysonPDUSessionRequested.h"
int encode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested alwaysonpdusessionrequested, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int encode_alwayson_pdu_session_requested(AlwaysonPDUSessionRequested alwaysonpdusessionrequested, uint8_t iei, uint8_t *buffer, uint32_t len) {
uint32_t encoded = 0;
uint8_t bitStream = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ALWAYSON_PDU_SESSION_REQUESTED_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ALWAYSON_PDU_SESSION_REQUESTED_MINIMUM_LENGTH, len);
if(iei > 0){
if (iei > 0) {
bitStream |= (iei & 0xf0);
}
if(alwaysonpdusessionrequested.apsr_requested)
if (alwaysonpdusessionrequested.apsr_requested)
bitStream |= 0x01;
ENCODE_U8(buffer+encoded,bitStream,encoded);
ENCODE_U8(buffer + encoded, bitStream, encoded);
return encoded;
}
int decode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested * alwaysonpdusessionrequested, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
int decode_alwayson_pdu_session_requested(AlwaysonPDUSessionRequested *alwaysonpdusessionrequested, uint8_t iei, uint8_t *buffer, uint32_t len) {
int decoded = 0;
uint8_t bitStream = 0;
DECODE_U8(buffer+decoded,bitStream,decoded);
DECODE_U8(buffer + decoded, bitStream, decoded);
if(iei != (bitStream&0xf0)){
if (iei != (bitStream & 0xf0)) {
return -1;
}
if(iei > 0){
if (iei > 0) {
bitStream = (bitStream & 0x01);
}
if(bitStream)
if (bitStream)
alwaysonpdusessionrequested->apsr_requested = true;
else
alwaysonpdusessionrequested->apsr_requested = false;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _ALWAYSONPDUSESSIONREQUESTED_H_
#define _ALWAYSONPDUSESSIONREQUESTED_H_
......@@ -11,12 +32,11 @@
#define ALWAYSON_PDU_SESSION_NOT_REQUESTED 0
#define ALWAYSON_PDU_SESSION_REQUESTED 1
typedef struct{
bool apsr_requested;
}AlwaysonPDUSessionRequested;
typedef struct {
bool apsr_requested;
} AlwaysonPDUSessionRequested;
int encode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested alwaysonpdusessionrequested, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested * alwaysonpdusessionrequested, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int encode_alwayson_pdu_session_requested(AlwaysonPDUSessionRequested alwaysonpdusessionrequested, uint8_t iei, uint8_t *buffer, uint32_t len);
int decode_alwayson_pdu_session_requested(AlwaysonPDUSessionRequested *alwaysonpdusessionrequested, uint8_t iei, uint8_t *buffer, uint32_t len);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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