Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Black
OpenXG-RAN
Commits
34424c77
Commit
34424c77
authored
Nov 28, 2022
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary ASN.1 macros and generation scripts
parent
feeb017e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
0 additions
and
1254 deletions
+0
-1254
cmake_targets/macros.cmake
cmake_targets/macros.cmake
+0
-15
cmake_targets/tools/asn1tostruct.py
cmake_targets/tools/asn1tostruct.py
+0
-697
cmake_targets/tools/fix_asn1
cmake_targets/tools/fix_asn1
+0
-221
cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff
...s/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff
+0
-23
cmake_targets/tools/fix_asn1.data/RRC.rel14/SystemInformation-NB-r13-IEs.h.diff
...x_asn1.data/RRC.rel14/SystemInformation-NB-r13-IEs.h.diff
+0
-47
cmake_targets/tools/fix_asn1.data/RRC.rel14/SystemInformation-r8-IEs.h.diff
...s/fix_asn1.data/RRC.rel14/SystemInformation-r8-IEs.h.diff
+0
-23
cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff
...a/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff
+0
-15
cmake_targets/tools/generate_asn1
cmake_targets/tools/generate_asn1
+0
-179
cmake_targets/tools/make_asn1c_includes.sh
cmake_targets/tools/make_asn1c_includes.sh
+0
-34
No files found.
cmake_targets/macros.cmake
View file @
34424c77
...
...
@@ -82,21 +82,6 @@ function(make_version VERSION_VALUE)
set
(
${
VERSION_VALUE
}
"
${
RESULT
}
"
PARENT_SCOPE
)
endfunction
()
macro
(
compile_asn1 asn1Source asn1cCmd ResultFlag
)
# Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
execute_process
(
COMMAND
${
asn1cCmd
}
${
asn1Source
}
RESULT_VARIABLE ret
)
if
(
NOT
${
ret
}
STREQUAL 0
)
message
(
FATAL_ERROR
"
${
ret
}
: error"
)
endif
(
NOT
${
ret
}
STREQUAL 0
)
add_custom_target
(
${
ResultFlag
}
ALL
${
asn1cCmd
}
${
asn1Source
}
DEPENDS
${
asn1Source
}
)
endmacro
(
compile_asn1
)
macro
(
eval_boolean VARIABLE
)
if
(
${
ARGN
}
)
set
(
${
VARIABLE
}
ON
)
...
...
cmake_targets/tools/asn1tostruct.py
deleted
100755 → 0
View file @
feeb017e
import
re
,
os
,
sys
,
string
import
datetime
import
getopt
import
getpass
version
=
"1.0.2"
lines
=
""
iesDefs
=
{}
ieofielist
=
{}
outdir
=
'./'
filenames
=
[]
verbosity
=
0
prefix
=
""
FAIL
=
'
\033
[91m'
WARN
=
'
\033
[93m'
ENDC
=
'
\033
[0m'
fileprefix
=
""
fileprefix_first_upper
=
""
def
printFail
(
string
):
sys
.
stderr
.
write
(
FAIL
+
string
+
ENDC
+
"
\n
"
)
def
printWarning
(
string
):
print
WARN
+
string
+
ENDC
def
printDebug
(
string
):
if
verbosity
>
0
:
print
string
def
outputHeaderToFile
(
f
,
filename
):
now
=
datetime
.
datetime
.
now
()
f
.
write
(
"""/*
* 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
*/
"""
)
f
.
write
(
"/*******************************************************************************
\n
"
)
f
.
write
(
" * This file had been created by asn1tostruct.py script v%s
\n
"
%
(
version
))
f
.
write
(
" * Please do not modify this file but regenerate it via script.
\n
"
)
f
.
write
(
" * Created on: %s by %s
\n
* from %s
\n
"
%
(
str
(
now
),
getpass
.
getuser
(),
filenames
))
f
.
write
(
" ******************************************************************************/
\n
"
)
def
lowerFirstCamelWord
(
word
):
""" puts the first word in a CamelCase Word in lowercase.
I.e. CustomerID becomes customerID, XMLInfoTest becomes xmlInfoTest
"""
newstr
=
''
swapped
=
word
.
swapcase
()
idx
=
0
# if it's all-caps, return an all-lowered version
lowered
=
word
.
lower
()
if
swapped
==
lowered
:
return
lowered
for
c
in
swapped
:
if
c
in
string
.
lowercase
:
newstr
+=
c
idx
+=
1
else
:
break
if
idx
<
2
:
newstr
+=
word
[
idx
:]
else
:
newstr
=
newstr
[:
-
1
]
+
word
[
idx
-
1
:]
return
newstr
def
usage
():
print
"Python parser for asn1 v%s"
%
(
version
)
print
"Usage: python asn1tostruct.py [options]"
print
"Available options:"
print
"-d Enable script debug"
print
"-f [file] Input file to parse"
print
"-o [dir] Output files to given directory"
print
"-h Print this help and return"
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"df:ho:"
,
[
"debug"
,
"file"
,
"help"
,
"outdir"
])
except
getopt
.
GetoptError
as
err
:
# print help information and exit:
usage
()
sys
.
exit
(
2
)
for
o
,
a
in
opts
:
if
o
in
(
"-f"
,
"--file"
):
filenames
.
append
(
a
)
if
o
in
(
"-d"
,
"--debug"
):
verbosity
=
1
if
o
in
(
"-o"
,
"--outdir"
):
outdir
=
a
if
outdir
.
rfind
(
'/'
)
!=
len
(
outdir
):
outdir
+=
'/'
if
o
in
(
"-h"
,
"--help"
):
usage
()
sys
.
exit
(
2
)
for
filename
in
filenames
:
file
=
open
(
filename
,
'r'
)
for
line
in
file
:
# Removing any comment
if
line
.
find
(
'--'
)
>=
0
:
line
=
line
[:
line
.
find
(
'--'
)]
# Removing any carriage return
lines
+=
re
.
sub
(
'
\r
'
,
''
,
line
)
for
m
in
re
.
findall
(
r'([a-zA-Z0-9-]+)\s*::=\s+SEQUENCE\s+\(\s*SIZE\s*\(\s*\d+\s*\.\.\s*[0-9a-zA-Z-]+\s*\)\s*\)\s*OF\s+[a-zA-Z-]+\s*\{\s*\{\s*([0-9a-zA-Z-]+)\s*\}\s*\}'
,
lines
,
re
.
MULTILINE
):
ieofielist
[
m
[
0
]]
=
m
[
1
]
for
m
in
re
.
findall
(
r'([a-zA-Z0-9-]+)\s*::=\s+E-RAB-IE-ContainerList\s*\{\s*\{\s*([a-zA-Z0-9-]+)\s*\}\s*\}'
,
lines
,
re
.
MULTILINE
):
ieofielist
[
m
[
0
]]
=
m
[
1
]
for
i
in
re
.
findall
(
r'([a-zA-Z0-9-]+)\s+([A-Z0-9-]+)\s*::=\s*\{\s+([\,\|\{\}\t\n\.{3}\ \-a-zA-Z0-9]+)\s+}\n'
,
lines
,
re
.
MULTILINE
):
ies
=
[]
maxLength
=
0
# TODO: handle extensions
if
i
[
1
].
find
(
'EXTENSION'
)
>=
0
:
continue
if
fileprefix
==
""
:
fileprefix
=
i
[
1
][:
i
[
1
].
find
(
'-'
)].
lower
()
for
j
in
re
.
findall
(
r'\s*\{\s*([a-zA-Z0-9-\ \t]+)\s*\}\s*[\|,]*'
,
i
[
2
],
re
.
MULTILINE
):
for
k
in
re
.
findall
(
r'ID\s*([a-zA-Z0-9\-]+)\s*CRITICALITY\s*([a-zA-Z0-9\-]+)\s+[A-Z]+\s+([a-zA-Z0-9\-]+)\s*PRESENCE\s*([a-zA-Z0-9\-]+)'
,
j
,
re
.
MULTILINE
):
printDebug
(
"Got new ie for message "
+
i
[
0
]
+
": "
+
str
(
k
))
if
len
(
k
[
2
])
>
maxLength
:
maxLength
=
len
(
k
[
2
])
ies
.
append
(
k
)
if
len
(
ies
)
>
0
:
iesDefs
[
i
[
0
]]
=
{
"length"
:
maxLength
,
"ies"
:
ies
}
else
:
printWarning
(
"Didn't find any information element for message: "
+
i
[
0
])
if
len
(
iesDefs
)
==
0
:
printFail
(
"No Information Element parsed, exiting"
)
sys
.
exit
(
0
)
fileprefix_first_upper
=
fileprefix
[
0
].
upper
()
+
fileprefix
[
1
:]
f
=
open
(
outdir
+
fileprefix
+
'_ies_defs.h'
,
'w'
)
outputHeaderToFile
(
f
,
filename
)
f
.
write
(
"#include
\"
%s_common.h
\"\n\n
"
%
(
fileprefix
))
f
.
write
(
"#ifndef %s_IES_DEFS_H_
\n
#define %s_IES_DEFS_H_
\n\n
"
%
(
fileprefix
.
upper
(),
fileprefix
.
upper
()))
f
.
write
(
"/* Define the version of script used to generate this file */
\n
"
)
f
.
write
(
"#define %s_SCRIPT_VERSION (%s)
\n\n
"
%
(
fileprefix
.
upper
(),
re
.
sub
(
'\.'
,
''
,
version
)))
for
key
in
iesDefs
:
if
key
not
in
ieofielist
.
values
():
continue
for
(
i
,
j
)
in
ieofielist
.
items
():
if
j
==
key
:
break
f
.
write
(
"typedef struct %sIEs_s {
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
i
)))
f
.
write
(
" A_SEQUENCE_OF(struct %s_s) %s;
\n
"
%
(
re
.
sub
(
'IEs'
,
''
,
re
.
sub
(
'-'
,
'_'
,
ieofielist
[
i
])),
lowerFirstCamelWord
(
re
.
sub
(
'IEs'
,
''
,
re
.
sub
(
'-'
,
'_'
,
ieofielist
[
i
])))))
f
.
write
(
"} %sIEs_t;
\n\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
i
)))
for
key
in
iesDefs
:
keyupperunderscore
=
re
.
sub
(
'-'
,
'_'
,
key
.
upper
())
keylowerunderscore
=
re
.
sub
(
'-'
,
'_'
,
key
.
lower
())
shift
=
0
if
len
(
iesDefs
[
key
][
"ies"
])
==
0
:
continue
# Presence mask
for
ie
in
iesDefs
[
key
][
"ies"
]:
ieupperunderscore
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'id-'
,
''
,
ie
[
0
])).
upper
()
if
ie
[
3
]
==
"optional"
or
ie
[
3
]
==
"conditional"
:
f
.
write
(
"#define {0:<{pad}} {1}
\n
"
.
format
(
"%s_%s_PRESENT"
%
(
keyupperunderscore
,
ieupperunderscore
),
"(1 << %d)"
%
shift
,
pad
=
iesDefs
[
key
][
"length"
]
+
len
(
keyupperunderscore
)
+
9
))
shift
+=
1
if
(
shift
>
0
):
f
.
write
(
"
\n
"
)
f
.
write
(
"typedef struct %s_s {
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
key
)))
if
(
shift
>
0
):
f
.
write
(
" {0:<{pad}} {1};
\n
"
.
format
(
"uint16_t"
,
"presenceMask"
,
pad
=
iesDefs
[
key
][
"length"
]
+
2
))
for
ie
in
iesDefs
[
key
][
"ies"
]:
ieunderscore
=
re
.
sub
(
'-'
,
'_'
,
ie
[
2
])
iename
=
re
.
sub
(
'id-'
,
''
,
ie
[
0
])
ienameunderscore
=
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
iename
))
if
ie
[
2
]
in
ieofielist
:
f
.
write
(
" %sIEs_t %s;"
%
(
re
.
sub
(
'-'
,
'_'
,
ie
[
2
]),
ienameunderscore
))
else
:
f
.
write
(
" {0:<{pad}} {1};"
.
format
(
"%s_t"
%
ieunderscore
,
ienameunderscore
,
pad
=
iesDefs
[
key
][
"length"
]
+
2
))
if
ie
[
3
]
==
"optional"
:
f
.
write
(
" ///< Optional field"
)
elif
ie
[
3
]
==
"conditional"
:
f
.
write
(
" ///< Conditional field"
)
f
.
write
(
"
\n
"
)
f
.
write
(
"} %s_t;
\n\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
key
)))
f
.
write
(
"typedef struct %s_message_s {
\n
"
%
(
fileprefix
))
f
.
write
(
" %s_ProcedureCode_t procedureCode;
\n
"
%
(
fileprefix_first_upper
))
f
.
write
(
" %s_Criticality_t criticality;
\n
"
%
(
fileprefix_first_upper
))
f
.
write
(
" uint8_t direction;
\n
"
)
f
.
write
(
" union {
\n
"
)
messageList
=
iesDefs
.
keys
()
messageList
.
sort
()
for
message
in
messageList
:
if
message
in
ieofielist
.
values
():
continue
if
len
(
iesDefs
[
message
][
"ies"
])
==
0
:
continue
f
.
write
(
" %s_t %s;
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
message
),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
message
))))
f
.
write
(
" } msg;
\n
"
)
f
.
write
(
"} %s_message;
\n\n
"
%
(
fileprefix
))
for
key
in
iesDefs
:
if
key
in
ieofielist
.
values
():
continue
structName
=
re
.
sub
(
'ies'
,
''
,
key
)
asn1cStruct
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'IEs'
,
''
,
re
.
sub
(
'-IEs'
,
''
,
key
)))
asn1cStruct
=
re
.
sub
(
'Item'
,
'List'
,
asn1cStruct
)
keylowerunderscore
=
re
.
sub
(
'-'
,
'_'
,
key
.
lower
())
firstlower
=
re
.
sub
(
'Item'
,
'List'
,
re
.
sub
(
'enb'
,
'eNB'
,
lowerFirstCamelWord
(
asn1cStruct
)))
f
.
write
(
"/**
\\
brief Decode function for %s ies.
\n
"
%
(
key
))
if
len
(
iesDefs
[
key
][
"ies"
])
!=
0
:
f
.
write
(
" *
\\
param %s Pointer to ASN1 structure in which data will be stored
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
f
.
write
(
" *
\\
param any_p Pointer to the ANY value to decode.
\n
"
)
f
.
write
(
" **/
\n
"
)
f
.
write
(
"int %s_decode_%s(
\n
"
%
(
fileprefix
,
keylowerunderscore
))
if
len
(
iesDefs
[
key
][
"ies"
])
!=
0
:
f
.
write
(
" %s_t *%s,
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
key
),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
f
.
write
(
" ANY_t *any_p);
\n\n
"
)
if
len
(
iesDefs
[
key
][
"ies"
])
==
0
:
continue
f
.
write
(
"/**
\\
brief Encode function for %s ies.
\n
"
%
(
key
))
f
.
write
(
" *
\\
param %s Pointer to the ASN1 structure.
\n
"
%
(
firstlower
))
f
.
write
(
" *
\\
param %s Pointer to the IES structure.
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
f
.
write
(
" **/
\n
"
)
f
.
write
(
"int %s_encode_%s(
\n
"
%
(
fileprefix
,
re
.
sub
(
'-'
,
'_'
,
structName
.
lower
())))
f
.
write
(
" %s_t *%s,
\n
"
%
(
asn1cStruct
,
firstlower
))
f
.
write
(
" %s_t *%s);
\n\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
key
),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
for
key
in
iesDefs
:
if
key
not
in
ieofielist
.
values
():
continue
asn1cStruct
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'IEs'
,
''
,
key
))
asn1cStruct
=
re
.
sub
(
'Item'
,
'List'
,
asn1cStruct
)
firstlower
=
re
.
sub
(
'Item'
,
'List'
,
re
.
sub
(
'enb'
,
'eNB'
,
lowerFirstCamelWord
(
asn1cStruct
)))
f
.
write
(
"/**
\\
brief Encode function for %s ies.
\n
"
%
(
key
))
f
.
write
(
" *
\\
param %s Pointer to the ASN1 structure.
\n
"
%
(
firstlower
))
f
.
write
(
" *
\\
param %s Pointer to the IES structure.
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
f
.
write
(
" **/
\n
"
)
f
.
write
(
"int %s_encode_%s(
\n
"
%
(
fileprefix
,
firstlower
.
lower
()))
f
.
write
(
" %s_t *%s,
\n
"
%
(
asn1cStruct
,
firstlower
))
f
.
write
(
" %sIEs_t *%sIEs);
\n\n
"
%
(
asn1cStruct
,
firstlower
))
f
.
write
(
"/**
\\
brief Decode function for %s ies.
\n
"
%
(
key
))
f
.
write
(
" *
\\
param any_p Pointer to the ANY value to decode.
\n
"
)
f
.
write
(
" *
\\
param callback Callback function called when any_p is successfully decoded.
\n
"
)
f
.
write
(
" **/
\n
"
)
f
.
write
(
"int %s_decode_%s(
\n
"
%
(
fileprefix
,
firstlower
.
lower
()))
f
.
write
(
" %sIEs_t *%sIEs,
\n
"
%
(
asn1cStruct
,
firstlower
))
f
.
write
(
" %s_t *%s);
\n\n
"
%
(
asn1cStruct
,
lowerFirstCamelWord
(
asn1cStruct
)))
for
key
in
iesDefs
:
asn1cStruct
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'IEs'
,
''
,
key
))
asn1cStruct
=
re
.
sub
(
'Item'
,
'List'
,
asn1cStruct
)
firstlower
=
re
.
sub
(
'Item'
,
'List'
,
re
.
sub
(
'enb'
,
'eNB'
,
lowerFirstCamelWord
(
asn1cStruct
)))
if
key
in
ieofielist
.
values
():
f
.
write
(
"/**
\\
brief Display %s encapsulated IE using XER encoding.
\n
"
%
(
asn1cStruct
))
f
.
write
(
" *
\\
param %s Pointer to the IES structure.
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
f
.
write
(
" *
\\
param file File descriptor to write output.
\n
"
)
f
.
write
(
" **/
\n
"
)
f
.
write
(
"asn_enc_rval_t %s_xer_print_%s(
\n
"
%
(
fileprefix
,
re
.
sub
(
'item'
,
'list'
,
firstlower
.
lower
())))
f
.
write
(
" asn_app_consume_bytes_f *cb,
\n
"
)
f
.
write
(
" void *app_key,
\n
"
)
f
.
write
(
" %sIEs_t *%sIEs);
\n\n
"
%
(
re
.
sub
(
'item'
,
'list'
,
asn1cStruct
),
firstlower
))
else
:
f
.
write
(
"/**
\\
brief Display %s message using XER encoding.
\n
"
%
(
asn1cStruct
))
f
.
write
(
" *
\\
param message_p Pointer to root message.
\n
"
)
f
.
write
(
" *
\\
param file File descriptor to write output.
\n
"
)
f
.
write
(
" **/
\n
"
)
f
.
write
(
"asn_enc_rval_t %s_xer_print_%s(
\n
"
%
(
fileprefix
,
firstlower
.
lower
()))
f
.
write
(
" asn_app_consume_bytes_f *cb,
\n
"
)
f
.
write
(
" void *app_key,
\n
"
)
f
.
write
(
" %s_message *message_p);
\n\n
"
%
(
fileprefix
))
f
.
write
(
"int %s_xer__print2sp(const void *buffer, size_t size, void *app_key);
\n\n
"
%
(
fileprefix
.
lower
()))
f
.
write
(
"int %s_xer__print2fp(const void *buffer, size_t size, void *app_key);
\n\n
"
%
(
fileprefix
.
lower
()))
f
.
write
(
"extern size_t %s_string_total_size;
\n\n
"
%
(
fileprefix
.
lower
()))
f
.
write
(
"#endif /* %s_IES_DEFS_H_ */
\n\n
"
%
(
fileprefix
.
upper
()))
#Generate Decode functions
f
=
open
(
outdir
+
fileprefix
+
'_decoder.c'
,
'w'
)
outputHeaderToFile
(
f
,
filename
)
f
.
write
(
"#include
\"
%s_common.h
\"\n
#include
\"
%s_ies_defs.h
\"\n\n
"
%
(
fileprefix
,
fileprefix
))
for
key
in
iesDefs
:
if
key
in
ieofielist
.
values
():
continue
structName
=
re
.
sub
(
'ies'
,
''
,
key
)
asn1cStruct
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'IEs'
,
''
,
key
))
if
asn1cStruct
.
rfind
(
'_'
)
==
len
(
asn1cStruct
)
-
1
:
asn1cStruct
=
asn1cStruct
[:
-
1
]
asn1cStruct
=
re
.
sub
(
'Item'
,
'List'
,
asn1cStruct
)
ielistname
=
re
.
sub
(
'UE'
,
'ue'
,
asn1cStruct
)
ielistnamefirstlower
=
ielistname
[:
1
].
lower
()
+
ielistname
[
1
:]
asn1cStructfirstlower
=
asn1cStruct
[:
1
].
lower
()
+
asn1cStruct
[
1
:]
keyName
=
re
.
sub
(
'-'
,
'_'
,
key
)
keyupperunderscore
=
keyName
.
upper
()
firstlower
=
re
.
sub
(
'Item'
,
'List'
,
re
.
sub
(
'enb'
,
'eNB'
,
lowerFirstCamelWord
(
asn1cStruct
)))
iesaccess
=
""
if
key
not
in
ieofielist
.
values
():
iesaccess
=
"%s_ies."
%
(
firstlower
)
f
.
write
(
"int %s_decode_%s(
\n
"
%
(
fileprefix
,
re
.
sub
(
'-'
,
'_'
,
structName
.
lower
())))
if
len
(
iesDefs
[
key
][
"ies"
])
!=
0
:
f
.
write
(
" %s_t *%s,
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
key
),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
f
.
write
(
" ANY_t *any_p) {
\n\n
"
)
f
.
write
(
" %s_t %s;
\n
%s_t *%s_p = &%s;
\n
"
%
(
asn1cStruct
,
asn1cStructfirstlower
,
asn1cStruct
,
asn1cStructfirstlower
,
asn1cStructfirstlower
))
f
.
write
(
" int i, decoded = 0;
\n
"
)
if
len
(
iesDefs
[
key
][
"ies"
])
!=
0
:
f
.
write
(
" int tempDecoded = 0;
\n
"
)
f
.
write
(
" assert(any_p != NULL);
\n
"
)
if
len
(
iesDefs
[
key
][
"ies"
])
!=
0
:
f
.
write
(
" assert(%s != NULL);
\n\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
f
.
write
(
" %s_DEBUG(
\"
Decoding message %s (%%s:%%d)
\\
n
\"
, __FILE__, __LINE__);
\n\n
"
%
(
fileprefix
.
upper
(),
re
.
sub
(
'-'
,
'_'
,
keyName
)))
f
.
write
(
" ANY_to_type_aper(any_p, &asn_DEF_%s, (void**)&%s_p);
\n\n
"
%
(
asn1cStruct
,
asn1cStructfirstlower
))
f
.
write
(
" for (i = 0; i < %s_p->%slist.count; i++) {
\n
"
%
(
asn1cStructfirstlower
,
iesaccess
))
f
.
write
(
" %s_IE_t *ie_p;
\n
"
%
(
fileprefix
[
0
].
upper
()
+
fileprefix
[
1
:]))
f
.
write
(
" ie_p = %s_p->%slist.array[i];
\n
"
%
(
asn1cStructfirstlower
,
iesaccess
))
f
.
write
(
" switch(ie_p->id) {
\n
"
)
for
ie
in
iesDefs
[
key
][
"ies"
]:
iename
=
re
.
sub
(
'id-'
,
''
,
ie
[
0
])
ienameunderscore
=
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
iename
))
ienameunderscorefirstlower
=
lowerFirstCamelWord
(
ienameunderscore
)
ietypesubst
=
re
.
sub
(
'-'
,
''
,
ie
[
2
])
ietypeunderscore
=
re
.
sub
(
'-'
,
'_'
,
ie
[
2
])
ieupperunderscore
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'id-'
,
''
,
ie
[
0
])).
upper
()
if
ie
[
3
]
==
"optional"
:
f
.
write
(
" /* Optional field */
\n
"
)
elif
ie
[
3
]
==
"conditional"
:
f
.
write
(
" /* Conditional field */
\n
"
)
f
.
write
(
" case %s_ProtocolIE_ID_%s:
\n
"
%
(
fileprefix_first_upper
,
re
.
sub
(
'-'
,
'_'
,
ie
[
0
])))
f
.
write
(
" {
\n
"
)
f
.
write
(
" %s_t *%s_p = NULL;
\n
"
%
(
ietypeunderscore
,
lowerFirstCamelWord
(
ietypesubst
)))
if
ie
[
3
]
!=
"mandatory"
:
f
.
write
(
" %s->presenceMask |= %s_%s_PRESENT;
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)),
keyupperunderscore
,
ieupperunderscore
))
f
.
write
(
" tempDecoded = ANY_to_type_aper(&ie_p->value, &asn_DEF_%s, (void**)&%s_p);
\n
"
%
(
ietypeunderscore
,
lowerFirstCamelWord
(
ietypesubst
)))
f
.
write
(
" if (tempDecoded < 0 || %s_p == NULL) {
\n
"
%
(
lowerFirstCamelWord
(
ietypesubst
)))
f
.
write
(
" %s_ERROR(
\"
Decoding of IE %s failed
\\
n
\"
);
\n
"
%
(
fileprefix
.
upper
(),
ienameunderscore
))
f
.
write
(
" if (%s_p)
\n
"
%
(
lowerFirstCamelWord
(
ietypesubst
)))
f
.
write
(
" ASN_STRUCT_FREE(asn_DEF_%s, %s_p);
\n
"
%
(
ietypeunderscore
,
lowerFirstCamelWord
(
ietypesubst
)))
f
.
write
(
" return -1;
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" decoded += tempDecoded;
\n
"
)
f
.
write
(
" if (asn1_xer_print)
\n
"
)
f
.
write
(
" xer_fprint(stdout, &asn_DEF_%s, %s_p);
\n
"
%
(
ietypeunderscore
,
lowerFirstCamelWord
(
ietypesubst
)))
if
ie
[
2
]
in
ieofielist
.
keys
():
f
.
write
(
" if (%s_decode_%s(&%s->%s, %s_p) < 0) {
\n
"
%
(
fileprefix
,
ietypeunderscore
.
lower
(),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)),
ienameunderscore
,
lowerFirstCamelWord
(
ietypesubst
)))
f
.
write
(
" %s_ERROR(
\"
Decoding of encapsulated IE %s failed
\\
n
\"
);
\n
"
%
(
fileprefix
.
upper
(),
lowerFirstCamelWord
(
ietypesubst
)))
f
.
write
(
" ASN_STRUCT_FREE(asn_DEF_%s, %s_p);
\n
"
%
(
ietypeunderscore
,
lowerFirstCamelWord
(
ietypesubst
)))
f
.
write
(
" }
\n
"
)
else
:
f
.
write
(
" memcpy(&%s->%s, %s_p, sizeof(%s_t));
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)),
ienameunderscore
,
lowerFirstCamelWord
(
ietypesubst
),
ietypeunderscore
))
#f.write(" ASN_STRUCT_FREE(asn_DEF_%s, %s_p);\n" % (ietypeunderscore, lowerFirstCamelWord(ietypesubst)))
f
.
write
(
" } break;
\n
"
)
f
.
write
(
" default:
\n
"
)
f
.
write
(
" %s_ERROR(
\"
Unknown protocol IE id (%%d) for message %s
\\
n
\"
, (int)ie_p->id);
\n
"
%
(
fileprefix
.
upper
(),
re
.
sub
(
'-'
,
'_'
,
structName
.
lower
())))
f
.
write
(
" return -1;
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" return decoded;
\n
"
)
f
.
write
(
"}
\n\n
"
)
for
key
in
iesDefs
:
if
key
not
in
ieofielist
.
values
():
continue
keyname
=
re
.
sub
(
'IEs'
,
''
,
re
.
sub
(
'Item'
,
'List'
,
key
))
f
.
write
(
"int %s_decode_%s(
\n
"
%
(
fileprefix
,
re
.
sub
(
'-'
,
'_'
,
keyname
).
lower
()))
f
.
write
(
" %sIEs_t *%sIEs,
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
keyname
),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
keyname
))))
f
.
write
(
" %s_t *%s) {
\n\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
keyname
),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
keyname
))))
f
.
write
(
" int i, decoded = 0;
\n
"
)
f
.
write
(
" int tempDecoded = 0;
\n\n
"
)
f
.
write
(
" assert(%s != NULL);
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
keyname
))));
f
.
write
(
" assert(%sIEs != NULL);
\n\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
keyname
))));
f
.
write
(
" for (i = 0; i < %s->list.count; i++) {
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
keyname
))))
f
.
write
(
" %s_IE_t *ie_p = %s->list.array[i];
\n
"
%
(
fileprefix
[
0
].
upper
()
+
fileprefix
[
1
:],
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
keyname
))))
f
.
write
(
" switch (ie_p->id) {
\n
"
)
for
ie
in
iesDefs
[
key
][
"ies"
]:
iename
=
re
.
sub
(
'id-'
,
''
,
ie
[
0
])
ienameunderscore
=
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
iename
))
f
.
write
(
" case %s_ProtocolIE_ID_%s:
\n
"
%
(
fileprefix_first_upper
,
re
.
sub
(
'-'
,
'_'
,
ie
[
0
])))
f
.
write
(
" {
\n
"
)
f
.
write
(
" %s_t *%s_p = NULL;
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
ie
[
2
]),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
''
,
ie
[
2
]))))
f
.
write
(
" tempDecoded = ANY_to_type_aper(&ie_p->value, &asn_DEF_%s, (void**)&%s_p);
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
ie
[
2
]),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
''
,
ie
[
2
]))))
f
.
write
(
" if (tempDecoded < 0 || %s_p == NULL) {
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
''
,
ie
[
2
]))))
f
.
write
(
" %s_ERROR(
\"
Decoding of IE %s for message %s failed
\\
n
\"
);
\n
"
%
(
fileprefix
.
upper
(),
ienameunderscore
,
re
.
sub
(
'-'
,
'_'
,
keyname
)))
f
.
write
(
" if (%s_p)
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
''
,
ie
[
2
]))))
#f.write(" free(%s_p);\n" % (lowerFirstCamelWord(re.sub('-', '', ie[2]))))
f
.
write
(
" ASN_STRUCT_FREE(asn_DEF_%s, %s_p);
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
ie
[
2
]),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
''
,
ie
[
2
]))))
f
.
write
(
" return -1;
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" decoded += tempDecoded;
\n
"
)
f
.
write
(
" if (asn1_xer_print)
\n
"
)
f
.
write
(
" xer_fprint(stdout, &asn_DEF_%s, %s_p);
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
ie
[
2
]),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
''
,
ie
[
2
]))))
f
.
write
(
" ASN_SEQUENCE_ADD(&%sIEs->%s, %s_p);
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
keyname
)),
re
.
sub
(
'IEs'
,
''
,
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
''
,
ie
[
2
]))))
f
.
write
(
" } break;
\n
"
)
f
.
write
(
" default:
\n
"
)
f
.
write
(
" %s_ERROR(
\"
Unknown protocol IE id (%%d) for message %s
\\
n
\"
, (int)ie_p->id);
\n
"
%
(
fileprefix
.
upper
(),
re
.
sub
(
'-'
,
'_'
,
structName
.
lower
())))
f
.
write
(
" return -1;
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" return decoded;
\n
"
)
f
.
write
(
"}
\n\n
"
)
#Generate IES Encode functions
f
=
open
(
outdir
+
fileprefix
+
'_encoder.c'
,
'w'
)
outputHeaderToFile
(
f
,
filename
)
f
.
write
(
"#include
\"
%s_common.h
\"\n
"
%
(
fileprefix
))
f
.
write
(
"#include
\"
%s_ies_defs.h
\"\n\n
"
%
(
fileprefix
))
for
key
in
iesDefs
:
if
key
in
ieofielist
.
values
():
continue
structName
=
re
.
sub
(
'ies'
,
''
,
key
)
asn1cStruct
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'IEs'
,
''
,
key
))
asn1cStruct
=
re
.
sub
(
'Item'
,
'List'
,
asn1cStruct
)
if
asn1cStruct
.
rfind
(
'_'
)
==
len
(
asn1cStruct
)
-
1
:
asn1cStruct
=
asn1cStruct
[:
-
1
]
asn1cStructfirstlower
=
asn1cStruct
[:
1
].
lower
()
+
asn1cStruct
[
1
:]
firstwordlower
=
re
.
sub
(
'Item'
,
'List'
,
re
.
sub
(
'enb'
,
'eNB'
,
lowerFirstCamelWord
(
asn1cStruct
)))
iesaccess
=
""
if
key
not
in
ieofielist
.
values
():
iesaccess
=
"%s_ies."
%
(
firstwordlower
)
keyName
=
re
.
sub
(
'-'
,
'_'
,
key
)
keyupperunderscore
=
keyName
.
upper
()
# No IE to encode...
if
len
(
iesDefs
[
key
][
"ies"
])
==
0
:
continue
f
.
write
(
"int %s_encode_%s(
\n
"
%
(
fileprefix
,
re
.
sub
(
'-'
,
'_'
,
structName
.
lower
())))
f
.
write
(
" %s_t *%s,
\n
"
%
(
asn1cStruct
,
firstwordlower
))
f
.
write
(
" %s_t *%s) {
\n\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
key
),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))))
f
.
write
(
" %s_IE_t *ie;
\n\n
"
%
(
fileprefix_first_upper
))
f
.
write
(
" assert(%s != NULL);
\n
"
%
(
firstwordlower
));
f
.
write
(
" assert(%s != NULL);
\n\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))));
for
ie
in
iesDefs
[
key
][
"ies"
]:
iename
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'id-'
,
''
,
ie
[
0
]))
ienameunderscore
=
re
.
sub
(
'-'
,
'_'
,
iename
)
ienamefirstwordlower
=
lowerFirstCamelWord
(
iename
)
ieupperunderscore
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'id-'
,
''
,
ie
[
0
])).
upper
()
ietypeunderscore
=
re
.
sub
(
'-'
,
'_'
,
ie
[
2
])
if
ie
[
3
]
!=
"mandatory"
:
if
ie
[
3
]
==
"optional"
:
f
.
write
(
" /* Optional field */
\n
"
)
elif
ie
[
3
]
==
"conditional"
:
f
.
write
(
" /* Conditional field */
\n
"
)
f
.
write
(
" if (%s->presenceMask & %s_%s_PRESENT) {
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)),
keyupperunderscore
,
ieupperunderscore
))
#f.write(" == %s_%s_PRESENT) {\n" % (keyupperunderscore, ieupperunderscore))
f
.
write
(
" if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,
\n
"
%
(
fileprefix
,
fileprefix_first_upper
,
re
.
sub
(
'-'
,
'_'
,
ie
[
0
])))
f
.
write
(
" %s_Criticality_%s,
\n
"
%
(
fileprefix_first_upper
,
ie
[
1
]))
f
.
write
(
" &asn_DEF_%s,
\n
"
%
(
ietypeunderscore
))
f
.
write
(
" &%s->%s)) == NULL) {
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)),
ienamefirstwordlower
))
f
.
write
(
" return -1;
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" ASN_SEQUENCE_ADD(&%s->%slist, ie);
\n
"
%
(
firstwordlower
,
iesaccess
))
f
.
write
(
" }
\n\n
"
)
else
:
if
ie
[
2
]
in
ieofielist
.
keys
():
f
.
write
(
" %s_t %s;
\n\n
"
%
(
ietypeunderscore
,
ienamefirstwordlower
))
f
.
write
(
" memset(&%s, 0, sizeof(%s_t));
\n
"
%
(
ienamefirstwordlower
,
ietypeunderscore
))
f
.
write
(
"
\n
"
)
f
.
write
(
" if (%s_encode_%s(&%s, &%s->%s) < 0) return -1;
\n
"
%
(
fileprefix
,
ietypeunderscore
.
lower
(),
ienamefirstwordlower
,
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)),
ienamefirstwordlower
))
f
.
write
(
" if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,
\n
"
%
(
fileprefix
,
fileprefix_first_upper
,
re
.
sub
(
'-'
,
'_'
,
ie
[
0
])))
f
.
write
(
" %s_Criticality_%s,
\n
"
%
(
fileprefix_first_upper
,
ie
[
1
]))
f
.
write
(
" &asn_DEF_%s,
\n
"
%
(
ietypeunderscore
))
if
ie
[
2
]
in
ieofielist
.
keys
():
f
.
write
(
" &%s)) == NULL) {
\n
"
%
(
ienamefirstwordlower
))
else
:
f
.
write
(
" &%s->%s)) == NULL) {
\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)),
ienamefirstwordlower
))
f
.
write
(
" return -1;
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" ASN_SEQUENCE_ADD(&%s->%slist, ie);
\n\n
"
%
(
firstwordlower
,
iesaccess
))
if
ie
[
2
]
in
ieofielist
.
keys
():
f
.
write
(
" /* Free any dynamic allocation that is no more used */
\n
"
)
f
.
write
(
" ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_%s, &%s);
\n\n
"
%
(
ietypeunderscore
,
ienamefirstwordlower
))
f
.
write
(
" return 0;
\n
"
)
f
.
write
(
"}
\n\n
"
)
for
(
key
,
value
)
in
iesDefs
.
items
():
if
key
not
in
ieofielist
.
values
():
continue
ie
=
value
[
"ies"
][
0
]
ietypeunderscore
=
re
.
sub
(
'-'
,
'_'
,
ie
[
2
])
asn1cStruct
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'IEs'
,
''
,
re
.
sub
(
'-IEs'
,
''
,
key
)))
asn1cStruct
=
re
.
sub
(
'Item'
,
'List'
,
asn1cStruct
)
firstwordlower
=
re
.
sub
(
'Item'
,
'List'
,
re
.
sub
(
'enb'
,
'eNB'
,
lowerFirstCamelWord
(
asn1cStruct
)))
for
(
i
,
j
)
in
ieofielist
.
items
():
if
j
==
key
:
break
f
.
write
(
"int %s_encode_%s(
\n
"
%
(
fileprefix
,
re
.
sub
(
'-'
,
'_'
,
i
).
lower
()))
f
.
write
(
" %s_t *%s,
\n
"
%
(
asn1cStruct
,
firstwordlower
))
f
.
write
(
" %sIEs_t *%sIEs) {
\n\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
i
),
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
i
))))
f
.
write
(
" int i;
\n
"
)
f
.
write
(
" %s_IE_t *ie;
\n\n
"
%
(
fileprefix_first_upper
))
f
.
write
(
" assert(%s != NULL);
\n
"
%
(
firstwordlower
));
f
.
write
(
" assert(%sIEs != NULL);
\n\n
"
%
(
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
i
))));
f
.
write
(
" for (i = 0; i < %sIEs->%s.count; i++) {
\n
"
%
(
firstwordlower
,
re
.
sub
(
'IEs'
,
''
,
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)))))
f
.
write
(
" if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,
\n
"
%
(
fileprefix
,
fileprefix_first_upper
,
re
.
sub
(
'-'
,
'_'
,
ie
[
0
])))
f
.
write
(
" %s_Criticality_%s,
\n
"
%
(
fileprefix_first_upper
,
ie
[
1
]))
f
.
write
(
" &asn_DEF_%s,
\n
"
%
(
ietypeunderscore
))
f
.
write
(
" %sIEs->%s.array[i])) == NULL) {
\n
"
%
(
firstwordlower
,
re
.
sub
(
'IEs'
,
''
,
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)))))
f
.
write
(
" return -1;
\n
"
)
f
.
write
(
" }
\n
"
)
f
.
write
(
" ASN_SEQUENCE_ADD(&%s->list, ie);
\n
"
%
(
firstwordlower
))
f
.
write
(
" }
\n
"
)
f
.
write
(
" return 0;
\n
"
)
f
.
write
(
"}
\n\n
"
)
#Generate xer print functions
f
=
open
(
outdir
+
fileprefix
+
'_xer_print.c'
,
'w'
)
outputHeaderToFile
(
f
,
filename
)
f
.
write
(
"#include <stdlib.h>
\n
"
)
f
.
write
(
"#include <stdio.h>
\n\n
"
)
f
.
write
(
"#include <asn_application.h>
\n
#include <asn_internal.h>
\n\n
"
)
f
.
write
(
"#include
\"
%s_common.h
\"\n
#include
\"
%s_ies_defs.h
\"\n\n
"
%
(
fileprefix
,
fileprefix
))
f
.
write
(
"size_t %s_string_total_size = 0;
\n\n
"
%
(
fileprefix
.
lower
()))
f
.
write
(
"""int
%s_xer__print2fp(const void *buffer, size_t size, void *app_key) {
FILE *stream = (FILE *)app_key;
if(fwrite(buffer, 1, size, stream) != size)
return -1;
return 0;
}
"""
%
(
fileprefix
.
lower
()))
f
.
write
(
"""int %s_xer__print2sp(const void *buffer, size_t size, void *app_key) {
char *string = (char *)app_key;
/* Copy buffer to the formatted string */
memcpy(&string[%s_string_total_size], buffer, size);
%s_string_total_size += size;
return 0;
}
"""
%
(
fileprefix
.
lower
(),
fileprefix
.
lower
(),
fileprefix
.
lower
()))
f
.
write
(
"""static asn_enc_rval_t
xer_encode_local(asn_TYPE_descriptor_t *td, void *sptr,
asn_app_consume_bytes_f *cb, void *app_key, int indent) {
asn_enc_rval_t er, tmper;
const char *mname;
size_t mlen;
int xcan = 2;
if(!td || !sptr) goto cb_failed;
mname = td->xml_tag;
mlen = strlen(mname);
_i_ASN_TEXT_INDENT(0, indent);
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
tmper = td->xer_encoder(td, sptr, indent + 1, XER_F_BASIC, cb, app_key);
if(tmper.encoded == -1) return tmper;
_ASN_CALLBACK3("</", 2, mname, mlen, ">
\\
n", xcan);
er.encoded = 4 + xcan + (2 * mlen) + tmper.encoded;
_ASN_ENCODED_OK(er);
cb_failed:
_ASN_ENCODE_FAILED;
}
"""
)
for
(
key
,
value
)
in
iesDefs
.
items
():
keyName
=
re
.
sub
(
'-'
,
'_'
,
key
)
keyupperunderscore
=
keyName
.
upper
()
iesStructName
=
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
))
ie
=
value
[
"ies"
][
0
]
ietypeunderscore
=
re
.
sub
(
'-'
,
'_'
,
ie
[
2
])
if
key
in
ieofielist
.
values
():
f
.
write
(
"asn_enc_rval_t %s_xer_print_%s(
\n
"
%
(
fileprefix
,
re
.
sub
(
'ies'
,
''
,
re
.
sub
(
'item'
,
'list'
,
re
.
sub
(
'-'
,
'_'
,
key
).
lower
()))))
else
:
f
.
write
(
"asn_enc_rval_t %s_xer_print_%s(
\n
"
%
(
fileprefix
,
re
.
sub
(
'ies'
,
''
,
re
.
sub
(
'-'
,
'_'
,
key
).
lower
())))
#f.write(" FILE *file,\n")
f
.
write
(
" asn_app_consume_bytes_f *cb,
\n
"
)
f
.
write
(
" void *app_key,
\n
"
)
if
key
in
ieofielist
.
values
():
iesStructName
=
lowerFirstCamelWord
(
re
.
sub
(
'Item'
,
'List'
,
re
.
sub
(
'-'
,
'_'
,
key
)))
f
.
write
(
" %sIEs_t *%s) {
\n\n
"
%
(
re
.
sub
(
'IEs'
,
''
,
re
.
sub
(
'Item'
,
'List'
,
re
.
sub
(
'-'
,
'_'
,
key
))),
iesStructName
))
f
.
write
(
" int i;
\n
"
)
f
.
write
(
" asn_enc_rval_t er;
\n
"
)
else
:
f
.
write
(
" %s_message *message_p)
\n
{
\n
"
%
(
fileprefix
))
f
.
write
(
" %s_t *%s;
\n
"
%
(
re
.
sub
(
'-'
,
'_'
,
key
),
iesStructName
))
f
.
write
(
" asn_enc_rval_t er;
\n
"
)
#f.write(" void *app_key = (void *)file;\n")
#f.write(" asn_app_consume_bytes_f *cb = %s_xer__print2fp;\n\n" % (fileprefix.lower()))
f
.
write
(
" %s = &message_p->msg.%s;
\n\n
"
%
(
iesStructName
,
iesStructName
))
if
key
in
ieofielist
.
values
():
# Increase indentation level
f
.
write
(
" for (i = 0; i < %s->%s.count; i++) {
\n
"
%
(
iesStructName
,
re
.
sub
(
'IEs'
,
''
,
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)))))
#f.write(" xer_fprint(file, &asn_DEF_%s, %s->%s.array[i]);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
f
.
write
(
" er = xer_encode(&asn_DEF_%s, %s->%s.array[i], XER_F_BASIC, cb, app_key);
\n
"
%
(
ietypeunderscore
,
iesStructName
,
re
.
sub
(
'IEs'
,
''
,
lowerFirstCamelWord
(
re
.
sub
(
'-'
,
'_'
,
key
)))))
f
.
write
(
" }
\n
"
)
else
:
f
.
write
(
" cb(
\"
<%s-PDU>
\\
n
\"
, %d, app_key);
\n
"
%
(
key
,
len
(
"<%s-PDU>
\n
"
%
(
key
))))
f
.
write
(
" xer_encode_local(&asn_DEF_%s_Criticality, &message_p->criticality, cb, app_key, 1);
\n
"
%
fileprefix_first_upper
)
f
.
write
(
" xer_encode_local(&asn_DEF_%s_ProcedureCode, &message_p->procedureCode, cb, app_key, 1);
\n
"
%
fileprefix_first_upper
)
f
.
write
(
" cb(
\"
<%s>
\\
n
\"
, %d, app_key);
\n
"
%
(
key
,
len
(
" <%s>
\n
"
%
(
key
))))
for
ie
in
iesDefs
[
key
][
"ies"
]:
iename
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'id-'
,
''
,
ie
[
0
]))
ienameunderscore
=
re
.
sub
(
'-'
,
'_'
,
iename
)
ienamefirstwordlower
=
lowerFirstCamelWord
(
iename
)
ietypeunderscore
=
re
.
sub
(
'-'
,
'_'
,
ie
[
2
])
ieupperunderscore
=
re
.
sub
(
'-'
,
'_'
,
re
.
sub
(
'id-'
,
''
,
ie
[
0
])).
upper
()
if
ie
[
3
]
!=
"mandatory"
:
if
ie
[
3
]
==
"optional"
:
f
.
write
(
" /* Optional field */
\n
"
)
elif
ie
[
3
]
==
"conditional"
:
f
.
write
(
" /* Conditional field */
\n
"
)
f
.
write
(
" if (%s->presenceMask & %s_%s_PRESENT)
\n
"
%
(
iesStructName
,
keyupperunderscore
,
ieupperunderscore
))
# Is it an encapsulated IE ?
if
ie
[
2
]
in
ieofielist
.
keys
():
f
.
write
(
" %s_xer_print_%s(cb, app_key, &%s->%s);
\n
"
%
(
fileprefix
,
re
.
sub
(
'ies'
,
''
,
re
.
sub
(
'-'
,
'_'
,
ie
[
2
]).
lower
()),
iesStructName
,
ienamefirstwordlower
))
else
:
f
.
write
(
" xer_encode_local(&asn_DEF_%s, &%s->%s, cb, app_key, 2);
\n
"
%
(
ietypeunderscore
,
iesStructName
,
ienamefirstwordlower
))
f
.
write
(
" cb(
\"
</%s>
\\
n
\"
, %d, app_key);
\n
"
%
(
key
,
len
(
" </%s>
\n
"
%
(
key
))))
f
.
write
(
" cb(
\"
</%s-PDU>
\\
n
\"
, %d, app_key);
\n
"
%
(
key
,
len
(
"</%s-PDU>
\n
"
%
(
key
))))
f
.
write
(
" _ASN_ENCODED_OK(er);
\n
"
)
#if key not in ieofielist.values():
#f.write("cb_failed:\n")
#f.write(" return er;\n")
f
.
write
(
"}
\n\n
"
)
cmake_targets/tools/fix_asn1
deleted
100755 → 0
View file @
feeb017e
#!/bin/bash
# in those arrays, each line is:
# <file> <sha1sum of file (without line 4 which changes depending on the location of the files)> <patch to apply to file>
RRC_Rel14
=(
"SystemInformation-r8-IEs.h"
4df485c5ddf2540eca271876cdc512caa19b0890
"fix_asn1.data/RRC.rel14/SystemInformation-r8-IEs.h.diff"
"SystemInformation-NB-r13-IEs.h"
6d91332d5c39205819b06e5e36efe62ff8e5b33b
"fix_asn1.data/RRC.rel14/SystemInformation-NB-r13-IEs.h.diff"
)
RRC_Rel10
=(
"SystemInformation-r8-IEs.h"
603cd6615cff36ec7020692d72c0d6de7c4859cb
"fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff"
)
X2AP_Rel11_2
=(
"X2ap-CriticalityDiagnostics-IE-List.h"
ae96308b37fcbcbf39da5012e42968135fc5f27b
"fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff"
)
red_color
=
"
$(
tput setaf 1
)
"
green_color
=
"
$(
tput setaf 2
)
"
reset_color
=
"
$(
tput sgr0
)
"
function
error
()
{
echo
-e
"
$red_color
"
ERROR:
"
$@
""
$reset_color
"
# exit 1
}
function
check_sha1
()
{
local
file
=
"
$1
"
local
target_sha1
=
"
$2
"
if
[
!
-f
"
$file
"
]
then
error
"
$file
: no such file"
fi
# we don't use the line 4 of the file
# it contains the location of the ASN1 grammar
# and this location is not the same on every
# installation (this is for *.h files, for *.c
# files it's no big deal to skip that line)
local
computed_sha1
=
$(
sed
4d
"
$file
"
|
sha1sum
|
cut
-f
1
-d
' '
)
if
[
"
$target_sha1
"
!=
"
$computed_sha1
"
]
then
error
"
$file
: wrong SHA1"
fi
}
function
patch_file
()
{
local
patch
=
"
$1
"
local
file
=
"
$2
"
echo
-e
"
$green_color
""patch file
$file
with
$OPENAIR_DIR
/cmake_targets/tools/
$patch
""
$reset_color
"
# patch "$file" "$OPENAIR_DIR/cmake_targets/tools/$patch"
# if [ $? -ne 0 ]
# then
# error "patching of $file with $OPENAIR_DIR/cmake_targets/tools/$patch failed"
# fi
}
function
apply_patches
()
{
local
directory
=
"
$1
"
local
array
=
$2
local
len
=
$3
# the length could be computed locally but the way to do it is not clear to me [CROUX]
local
i
local
file
local
sha1
local
patch
local
item
for
((
i
=
0
;
i <
$len
;
i +
=
3
))
do
# special bash syntax to access the array
item
=
$array
[
$i
]
;
file
=
${
!item
}
item
=
$array
[
$((
i+1
))
]
;
sha1
=
${
!item
}
item
=
$array
[
$((
i+2
))
]
;
patch
=
${
!item
}
check_sha1
"
$directory
/
$file
"
"
$sha1
"
patch_file
"
$patch
"
"
$directory
/
$file
"
done
}
function
patch_rrc
()
{
local
directory
=
"
$1
"
local
version
=
"
$2
"
case
"
$version
"
in
Rel14
)
echo
"patching RRC files release 14"
#apply_patches "$directory" RRC_Rel14 ${#RRC_Rel14[*]}
;;
Rel10
)
echo
"patching RRC files release 10"
apply_patches
"
$directory
"
RRC_Rel10
${#
RRC_Rel10
[*]
}
;;
Rel8
)
echo
"patching RRC files release 8 TODO?"
;;
*
)
error unknwon/unhandled RRC version
\'
"
$version
"
\'
;;
esac
}
function
patch_nr_rrc
()
{
local
directory
=
"
$1
"
local
version
=
"
$2
"
case
"
$version
"
in
NR_Rel15
)
echo
"patching NR_RRC files release 15"
apply_patches
"
$directory
"
NR_RRC_Rel15
${#
NR_RRC_Rel15
[*]
}
;;
*
)
error unknwon/unhandled NR_RRC version
\'
"
$version
"
\'
;;
esac
}
function
patch_x2ap
()
{
local
directory
=
"
$1
"
local
version
=
"
$2
"
case
"
$version
"
in
R14
)
;;
R11
)
echo
"patching X2AP files release 11.2"
apply_patches
"
$directory
"
X2AP_Rel11_2
${#
X2AP_Rel11_2
[*]
}
;;
*
)
error unknwon/unhandled X2AP version
\'
"
$version
"
\'
;;
esac
}
function
patch_s1ap
()
{
local
directory
=
"
$1
"
local
version
=
"
$2
"
case
"
$version
"
in
R14
)
;;
R10
)
#nothing to do anymore (fixes went to asn1c)
;;
*
)
error unknwon/unhandled S1AP version
\'
"
$version
"
\'
;;
esac
}
function
patch_f1ap
()
{
local
directory
=
"
$1
"
local
version
=
"
$2
"
case
"
$version
"
in
R15
)
#nothing to do anymore (fixes went to asn1c)
;;
*
)
error unknwon/unhandled F1AP version
\'
"
$version
"
\'
;;
esac
}
function
main
()
{
if
[
$#
-ne
3
]
then
echo
"ERROR: pass <output directory> <module> <version>"
exit
1
fi
if
[
x
"
$OPENAIR_DIR
"
=
x
]
then
error
"the variable OPENAIR_DIR is not set"
fi
local
directory
=
"
$1
"
local
module
=
"
$2
"
local
version
=
"
$3
"
case
"
$module
"
in
RRC
)
patch_rrc
"
$directory
"
"
$version
"
;;
NR_RRC
)
patch_nr_rrc
"
$directory
"
"
$version
"
;;
X2AP
)
patch_x2ap
"
$directory
"
"
$version
"
;;
S1AP
)
patch_s1ap
"
$directory
"
"
$version
"
;;
F1AP
)
patch_f1ap
"
$directory
"
"
$version
"
;;
*
)
error unknown module
"
$module
"
;;
esac
exit
0
}
main
"
$@
"
cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff
deleted
100755 → 0
View file @
feeb017e
57,61d56
< /* SystemInformation-r8-IEs */
< typedef struct SystemInformation_r8_IEs {
< struct SystemInformation_r8_IEs__sib_TypeAndInfo {
< A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member {
< SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present;
79c74,78
< } choice;
---
> };
>
> struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member {
> SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present;
> union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u choice;
83c82,87
< } ) list;
---
> };
>
> /* SystemInformation-r8-IEs */
> typedef struct SystemInformation_r8_IEs {
> struct SystemInformation_r8_IEs__sib_TypeAndInfo {
> A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member) list;
cmake_targets/tools/fix_asn1.data/RRC.rel14/SystemInformation-NB-r13-IEs.h.diff
deleted
100755 → 0
View file @
feeb017e
48a49,70
> struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member {
> SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member_PR present;
> union SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member_u {
> SystemInformationBlockType2_NB_r13_t sib2_r13;
> SystemInformationBlockType3_NB_r13_t sib3_r13;
> SystemInformationBlockType4_NB_r13_t sib4_r13;
> SystemInformationBlockType5_NB_r13_t sib5_r13;
> SystemInformationBlockType14_NB_r13_t sib14_r13;
> SystemInformationBlockType16_NB_r13_t sib16_r13;
> /*
> * This type is extensible,
> * possible extensions are below.
> */
> SystemInformationBlockType15_NB_r14_t sib15_v1430;
> SystemInformationBlockType20_NB_r14_t sib20_v1430;
> SystemInformationBlockType22_NB_r14_t sib22_v1430;
> } choice;
>
> /* Context for parsing across buffer boundaries */
> asn_struct_ctx_t _asn_ctx;
> };
>
52,72c74
< A_SEQUENCE_OF(struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member {
< SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member_PR present;
< union SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member_u {
< SystemInformationBlockType2_NB_r13_t sib2_r13;
< SystemInformationBlockType3_NB_r13_t sib3_r13;
< SystemInformationBlockType4_NB_r13_t sib4_r13;
< SystemInformationBlockType5_NB_r13_t sib5_r13;
< SystemInformationBlockType14_NB_r13_t sib14_r13;
< SystemInformationBlockType16_NB_r13_t sib16_r13;
< /*
< * This type is extensible,
< * possible extensions are below.
< */
< SystemInformationBlockType15_NB_r14_t sib15_v1430;
< SystemInformationBlockType20_NB_r14_t sib20_v1430;
< SystemInformationBlockType22_NB_r14_t sib22_v1430;
< } choice;
<
< /* Context for parsing across buffer boundaries */
< asn_struct_ctx_t _asn_ctx;
< } ) list;
---
> A_SEQUENCE_OF(struct SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member) list;
cmake_targets/tools/fix_asn1.data/RRC.rel14/SystemInformation-r8-IEs.h.diff
deleted
100755 → 0
View file @
feeb017e
73,77d72
< /* SystemInformation-r8-IEs */
< typedef struct SystemInformation_r8_IEs {
< struct SystemInformation_r8_IEs__sib_TypeAndInfo {
< A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member {
< SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present;
103c98,102
< } choice;
---
> };
>
> struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member {
> SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present;
> union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u choice;
107c106,111
< } ) list;
---
> };
>
> /* SystemInformation-r8-IEs */
> typedef struct SystemInformation_r8_IEs {
> struct SystemInformation_r8_IEs__sib_TypeAndInfo {
> A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member) list;
cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff
deleted
100755 → 0
View file @
feeb017e
29,31c29
< /* X2ap-CriticalityDiagnostics-IE-List */
< typedef struct X2ap_CriticalityDiagnostics_IE_List {
< A_SEQUENCE_OF(struct X2ap_CriticalityDiagnostics_IE_List__Member {
---
> struct X2ap_CriticalityDiagnostics_IE_List__Member {
43c41,46
< } ) list;
---
> };
>
> /* X2ap-CriticalityDiagnostics-IE-List */
> typedef struct X2ap_CriticalityDiagnostics_IE_List {
> A_SEQUENCE_OF(struct X2ap_CriticalityDiagnostics_IE_List__Member
> ) list;
cmake_targets/tools/generate_asn1
deleted
100755 → 0
View file @
feeb017e
#!/bin/bash
function
main
()
{
PROTOCOL_DIR
=
$1
mkdir
-p
${
PROTOCOL_DIR
}
cd
${
PROTOCOL_DIR
}
# Because use $* also include directory, so we need shift
shift
local
module
=
"
$2
"
#if this script is called with only 2 arguments (so 1 here after the shift), it's for RRC
#(there may be a better way...)
if
[
$#
-eq
2
]
;
then
#asn1c does not work well with extension groups, we need the following fix:
# replace [[ by '<name> SEQUENCE {'
# and ]] by '} OPTIONAL'
#<name> is ext<N> with N starting from 1 and incremented at each new [[ ]] just
#following another [[ ]]
#
#this is what the following C program does
echo
generate asnfix.c
cat
<<
EOF
> asnfix.c
/* transforms:
* '[[' to 'name SEQUENCE {'
* ']]' to '} OPTIONAL'
* name is ext1, ext2, ..., for each [[ at the same level
* levels are delimited by { and }
* -- to end of line is a comment and unprocessed
* nested [[ ]] not handled
* { and } must be balanced
* [[ and ]] can be whatever, every combination is valid
*/
#include <stdio.h>
#include <stdlib.h>
void level(int toplevel)
{
int c;
int next_name = 1;
while (1) {
c = getchar();
next:
if (c == EOF) { if (toplevel) break; abort(); }
if (c == '-') {
c = getchar();
if (c != '-') { putchar('-'); goto next; }
putchar(c); putchar(c);
while (1) {
c = getchar(); if (c == EOF) abort();
putchar(c);
if (c == '
\n
') break;
}
continue;
}
if (c == '[') {
c = getchar();
if (c != '[') { putchar('['); goto next; }
printf("ext%d SEQUENCE {", next_name);
next_name++;
continue;
}
if (c == ']') {
c = getchar();
if (c != ']') { putchar(']'); goto next; }
printf("} OPTIONAL");
continue;
}
putchar(c);
if (c == '}') { if (toplevel) abort(); break; }
if (c == '{') level(0);
}
}
int main(void)
{
level(1);
fflush(stdout);
return 0;
}
EOF
echo
compile asnfix.c
gcc
-Wall
-o
asnfix asnfix.c
echo
run asnfix on
$1
./asnfix <
$1
>
fixed_grammar.asn
rm
-f
asnfix asnfix.c
echo
done
with asnfix
echo
running asn1c
case
"
$module
"
in
RRC
)
asn1c
-gen-PER
-fcompound-names
-no-gen-example
fixed_grammar.asn 2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
;;
NR_RRC
)
export
ASN1C_PREFIX
=
NR_
asn1c
-gen-PER
-fcompound-names
-findirect-choice
-no-gen-example
fixed_grammar.asn 2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
;;
S1AP
)
export
ASN1C_PREFIX
=
S1AP_
asn1c
-gen-PER
-fcompound-names
-no-gen-example
fixed_grammar.asn 2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
;;
X2AP
)
export
ASN1C_PREFIX
=
X2AP_
asn1c
-gen-PER
-fcompound-names
-no-gen-example
fixed_grammar.asn 2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
;;
esac
rm
-f
fixed_grammar.asn
echo
asn1c
done
elif
echo
${
PROTOCOL_DIR
}
|
grep
-q
"F1AP"
;
then
asn1c
-gen-PER
-fcompound-names
-no-gen-example
-findirect-choice
-fno-include-deps
$*
2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
else
case
"
$module
"
in
RRC
)
asn1c
-pdu
=
all
-fcompound-names
-gen-PER
-no-gen-OER
-no-gen-example
$*
2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
;;
NR_RRC
)
export
ASN1C_PREFIX
=
NR_
asn1c
-fcompound-names
-findirect-choice
-fno-include-deps
-gen-PER
-no-gen-OER
-no-gen-example
$*
2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
;;
S1AP
)
export
ASN1C_PREFIX
=
S1AP_
asn1c
-fcompound-names
-fno-include-deps
-gen-PER
-no-gen-OER
-no-gen-example
$*
2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
;;
X2AP
)
export
ASN1C_PREFIX
=
X2AP_
asn1c
-fcompound-names
-fno-include-deps
-gen-PER
-no-gen-OER
-no-gen-example
$*
2>&1 |
grep
-v
--
'->'
|
grep
-v
'^Compiled'
|grep
-v
sample
;;
esac
fi
awk
'
BEGIN {
print "#ifndef __ASN1_CONSTANTS_H__"
print "#define __ASN1_CONSTANTS_H__"
}
/INTEGER ::=/ {
gsub("INTEGER ::=","")
gsub("--","//")
gsub("-1","_minus_1")
gsub("-","_")
printf("#define %s\n",$0)
}
/::=.*INTEGER.*[(]/ {
nb_fields=split($0,val,"[:=().]+");
gsub("-","_",val[1]);
printf("#define min_val_%s %s\n",val[1],val[nb_fields-2]);
printf("#define max_val_%s %s\n",val[1],val[nb_fields-1]);
}
END {
print "#endif ";
} '
$1
>
asn1_constants.h
}
main
"
$@
"
cmake_targets/tools/make_asn1c_includes.sh
deleted
100755 → 0
View file @
feeb017e
#!/bin/bash
export
ASN1C_PREFIX
=
$1
shift
options
=
$1
shift
GENERATED_FULL_DIR
=
$1
shift
ASN1_SOURCE_DIR
=
$*
done_flag
=
"
$GENERATED_FULL_DIR
"
/done
rebuild
=
0
for
f
in
$ASN1_SOURCE_DIR
;
do
if
[
"
$done_flag
"
-ot
"
$f
"
]
;
then
rebuild
=
1
fi
done
if
[
$rebuild
-eq
1
]
;
then
rm
-f
"
$GENERATED_FULL_DIR
"
/
${
ASN1C_PREFIX
}*
.c
"
$GENERATED_FULL_DIR
"
/
${
ASN1C_PREFIX
}*
.h
mkdir
-p
"
$GENERATED_FULL_DIR
"
asn1c
-pdu
=
all
-fcompound-names
-gen-PER
-no-gen-OER
-no-gen-example
$options
-D
$GENERATED_FULL_DIR
$ASN1_SOURCE_DIR
|& egrep
-v
"^Copied|^Compiled"
|
sort
-u
if
[
"
$ASN1C_PREFIX
"
=
"X2AP_"
]
;
then
sed
-i
's/18446744073709551615))/18446744073709551615U))/g'
"
$GENERATED_FULL_DIR
"
/
${
ASN1C_PREFIX
}
E-RABUsageReport-Item.c
sed
-i
's/18446744073709551615 }/18446744073709551615U }/g'
"
$GENERATED_FULL_DIR
"
/
${
ASN1C_PREFIX
}
E-RABUsageReport-Item.c
fi
if
[
"
$ASN1C_PREFIX
"
=
"S1AP_"
]
;
then
sed
-i
's/18446744073709551615))/18446744073709551615U))/g'
"
$GENERATED_FULL_DIR
"
/
${
ASN1C_PREFIX
}
E-RABUsageReportItem.c
sed
-i
's/18446744073709551615 }/18446744073709551615U }/g'
"
$GENERATED_FULL_DIR
"
/
${
ASN1C_PREFIX
}
E-RABUsageReportItem.c
fi
if
[
"
$ASN1C_PREFIX
"
=
"NGAP_"
]
;
then
sed
-i
's/18446744073709551615))/18446744073709551615U))/g'
"
$GENERATED_FULL_DIR
"
/
${
ASN1C_PREFIX
}
VolumeTimedReport-Item.c
sed
-i
's/18446744073709551615 }/18446744073709551615U }/g'
"
$GENERATED_FULL_DIR
"
/
${
ASN1C_PREFIX
}
VolumeTimedReport-Item.c
fi
fi
touch
$done_flag
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment