Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
16
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
cf68fb60
Commit
cf68fb60
authored
6 months ago
by
Dmitry Puzyrkov
Browse files
Options
Downloads
Patches
Plain Diff
[*] mmdbinstall
parent
93b94ff5
No related branches found
Branches containing commit
No related tags found
1 merge request
!1772
[*] mmdbinstall
Pipeline
#43789
passed with stage
in 36 minutes and 21 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
3rdparty/libmaxminddb/CMakeLists.txt
+15
-2
15 additions, 2 deletions
3rdparty/libmaxminddb/CMakeLists.txt
3rdparty/libmaxminddb/maxminddb.c
+91
-0
91 additions, 0 deletions
3rdparty/libmaxminddb/maxminddb.c
3rdparty/libmaxminddb/maxminddb.h
+3
-0
3 additions, 0 deletions
3rdparty/libmaxminddb/maxminddb.h
with
109 additions
and
2 deletions
3rdparty/libmaxminddb/CMakeLists.txt
+
15
−
2
View file @
cf68fb60
...
@@ -5,11 +5,24 @@ project(maxminddb C)
...
@@ -5,11 +5,24 @@ project(maxminddb C)
add_definitions
(
"-D_GNU_SOURCE"
)
add_definitions
(
"-D_GNU_SOURCE"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fPIC"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fPIC"
)
file
(
GLOB maxminddb_src
${
CMAKE_CURRENT_SOURCE_DIR
}
*.c
)
file
(
GLOB maxminddb_src
${
CMAKE_CURRENT_SOURCE_DIR
}
/
*.c
)
file
(
GLOB maxminddb_h
${
CMAKE_CURRENT_SOURCE_DIR
}
*.h
)
file
(
GLOB maxminddb_h
${
CMAKE_CURRENT_SOURCE_DIR
}
/
*.h
)
add_library
(
${
PROJECT_NAME
}
STATIC
${
maxminddb_src
}
${
maxminddb_h
}
)
add_library
(
${
PROJECT_NAME
}
STATIC
${
maxminddb_src
}
${
maxminddb_h
}
)
set_target_properties
(
${
PROJECT_NAME
}
PROPERTIES LINKER_LANGUAGE C
)
set_target_properties
(
${
PROJECT_NAME
}
PROPERTIES LINKER_LANGUAGE C
)
set_target_properties
(
${
PROJECT_NAME
}
PROPERTIES COMPILER_LANGUAGE C
)
set_target_properties
(
${
PROJECT_NAME
}
PROPERTIES COMPILER_LANGUAGE C
)
target_include_directories
(
${
PROJECT_NAME
}
INTERFACE .
)
target_include_directories
(
${
PROJECT_NAME
}
INTERFACE .
)
target_compile_options
(
${
PROJECT_NAME
}
PRIVATE -Wno-sign-compare
)
target_compile_options
(
${
PROJECT_NAME
}
PRIVATE -Wno-sign-compare
)
if
(
INSTALL_SDK
)
set_target_properties
(
${
PROJECT_NAME
}
PROPERTIES PUBLIC_HEADER
"
${
maxminddb_h
}
"
)
INSTALL
(
TARGETS
${
PROJECT_NAME
}
LIBRARY DESTINATION lib/modules/net/
ARCHIVE DESTINATION lib/modules/net/
PUBLIC_HEADER DESTINATION include/modules/net/maxminddb/
)
endif
()
This diff is collapsed.
Click to expand it.
3rdparty/libmaxminddb/maxminddb.c
+
91
−
0
View file @
cf68fb60
...
@@ -220,6 +220,97 @@ LOCAL char *bytes_to_hex(uint8_t *bytes, uint32_t size);
...
@@ -220,6 +220,97 @@ LOCAL char *bytes_to_hex(uint8_t *bytes, uint32_t size);
#define FREE_AND_SET_NULL(p) { free((void *)(p)); (p) = NULL; }
#define FREE_AND_SET_NULL(p) { free((void *)(p)); (p) = NULL; }
int
MMDB_open_memory
(
const
char
*
const
mem
,
ssize_t
size
,
MMDB_s
*
const
mmdb
)
{
if
(
NULL
==
mem
||
size
<=
0
)
{
return
MMDB_OUT_OF_MEMORY_ERROR
;
}
int
status
=
MMDB_SUCCESS
;
mmdb
->
file_content
=
NULL
;
mmdb
->
data_section
=
NULL
;
mmdb
->
metadata
.
database_type
=
NULL
;
mmdb
->
metadata
.
languages
.
count
=
0
;
mmdb
->
metadata
.
languages
.
names
=
NULL
;
mmdb
->
metadata
.
description
.
count
=
0
;
mmdb
->
filename
=
NULL
;
mmdb
->
file_size
=
size
;
mmdb
->
file_content
=
mem
;
#ifdef _WIN32
WSADATA
wsa
;
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsa
);
#endif
uint32_t
metadata_size
=
0
;
const
uint8_t
*
metadata
=
find_metadata
(
mmdb
->
file_content
,
mmdb
->
file_size
,
&
metadata_size
);
if
(
NULL
==
metadata
)
{
status
=
MMDB_INVALID_METADATA_ERROR
;
goto
cleanup
;
}
mmdb
->
metadata_section
=
metadata
;
mmdb
->
metadata_section_size
=
metadata_size
;
status
=
read_metadata
(
mmdb
);
if
(
MMDB_SUCCESS
!=
status
)
{
goto
cleanup
;
}
if
(
mmdb
->
metadata
.
binary_format_major_version
!=
2
)
{
status
=
MMDB_UNKNOWN_DATABASE_FORMAT_ERROR
;
goto
cleanup
;
}
uint32_t
search_tree_size
=
mmdb
->
metadata
.
node_count
*
mmdb
->
full_record_byte_size
;
mmdb
->
data_section
=
mmdb
->
file_content
+
search_tree_size
+
MMDB_DATA_SECTION_SEPARATOR
;
if
(
search_tree_size
+
MMDB_DATA_SECTION_SEPARATOR
>
(
uint32_t
)
mmdb
->
file_size
)
{
status
=
MMDB_INVALID_METADATA_ERROR
;
goto
cleanup
;
}
mmdb
->
data_section_size
=
(
uint32_t
)
mmdb
->
file_size
-
search_tree_size
-
MMDB_DATA_SECTION_SEPARATOR
;
// Although it is likely not possible to construct a database with valid
// valid metadata, as parsed above, and a data_section_size less than 3,
// we do this check as later we assume it is at least three when doing
// bound checks.
if
(
mmdb
->
data_section_size
<
3
)
{
status
=
MMDB_INVALID_DATA_ERROR
;
goto
cleanup
;
}
mmdb
->
metadata_section
=
metadata
;
mmdb
->
ipv4_start_node
.
node_value
=
0
;
mmdb
->
ipv4_start_node
.
netmask
=
0
;
// We do this immediately as otherwise there is a race to set
// ipv4_start_node.node_value and ipv4_start_node.netmask.
if
(
mmdb
->
metadata
.
ip_version
==
6
)
{
status
=
find_ipv4_start_node
(
mmdb
);
if
(
status
!=
MMDB_SUCCESS
)
{
goto
cleanup
;
}
}
cleanup:
if
(
MMDB_SUCCESS
!=
status
)
{
int
saved_errno
=
errno
;
free_mmdb_struct
(
mmdb
);
errno
=
saved_errno
;
}
return
status
;
}
int
MMDB_open
(
const
char
*
const
filename
,
uint32_t
flags
,
MMDB_s
*
const
mmdb
)
int
MMDB_open
(
const
char
*
const
filename
,
uint32_t
flags
,
MMDB_s
*
const
mmdb
)
{
{
int
status
=
MMDB_SUCCESS
;
int
status
=
MMDB_SUCCESS
;
...
...
This diff is collapsed.
Click to expand it.
3rdparty/libmaxminddb/maxminddb.h
+
3
−
0
View file @
cf68fb60
...
@@ -215,6 +215,9 @@ typedef struct MMDB_search_node_s {
...
@@ -215,6 +215,9 @@ typedef struct MMDB_search_node_s {
extern
int
MMDB_open
(
const
char
*
const
filename
,
uint32_t
flags
,
extern
int
MMDB_open
(
const
char
*
const
filename
,
uint32_t
flags
,
MMDB_s
*
const
mmdb
);
MMDB_s
*
const
mmdb
);
extern
int
MMDB_open_memory
(
const
char
*
const
mem
,
ssize_t
size
,
MMDB_s
*
const
mmdb
);
extern
MMDB_lookup_result_s
MMDB_lookup_string
(
const
MMDB_s
*
const
mmdb
,
extern
MMDB_lookup_result_s
MMDB_lookup_string
(
const
MMDB_s
*
const
mmdb
,
const
char
*
const
ipstr
,
const
char
*
const
ipstr
,
int
*
const
gai_error
,
int
*
const
gai_error
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment