Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libloc
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
nexedi
libloc
Commits
82910b95
Commit
82910b95
authored
Oct 03, 2019
by
Michael Tremer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement filtering networks for the ASN they belong to
Signed-off-by:
Michael Tremer
<
michael.tremer@ipfire.org
>
parent
74fb733a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
0 deletions
+22
-0
src/database.c
src/database.c
+14
-0
src/libloc.sym
src/libloc.sym
+2
-0
src/loc/database.h
src/loc/database.h
+1
-0
src/loc/network.h
src/loc/network.h
+1
-0
src/network.c
src/network.c
+4
-0
No files found.
src/database.c
View file @
82910b95
...
...
@@ -78,6 +78,7 @@ struct loc_database_enumerator {
// Search string
char
*
string
;
char
country_code
[
3
];
uint32_t
asn
;
// Index of the AS we are looking at
unsigned
int
as_index
;
...
...
@@ -651,6 +652,13 @@ LOC_EXPORT int loc_database_enumerator_set_country_code(struct loc_database_enum
return
0
;
}
LOC_EXPORT
int
loc_database_enumerator_set_asn
(
struct
loc_database_enumerator
*
enumerator
,
unsigned
int
asn
)
{
enumerator
->
asn
=
asn
;
return
0
;
}
LOC_EXPORT
struct
loc_as
*
loc_database_enumerator_next_as
(
struct
loc_database_enumerator
*
enumerator
)
{
struct
loc_database
*
db
=
enumerator
->
db
;
struct
loc_as
*
as
;
...
...
@@ -771,6 +779,12 @@ static int loc_database_enumerator_network_depth_first_search(
continue
;
}
// Skip if the ASN does not match
if
(
e
->
asn
&&
!
loc_network_match_asn
(
*
network
,
e
->
asn
))
{
loc_network_unref
(
*
network
);
continue
;
}
return
0
;
}
}
...
...
src/libloc.sym
View file @
82910b95
...
...
@@ -55,6 +55,7 @@ global:
loc_database_enumerator_next_as;
loc_database_enumerator_next_network;
loc_database_enumerator_ref;
loc_database_enumerator_set_asn;
loc_database_enumerator_set_country_code;
loc_database_enumerator_set_string;
loc_database_enumerator_unref;
...
...
@@ -62,6 +63,7 @@ global:
# Network
loc_network_get_asn;
loc_network_get_country_code;
loc_network_match_asn;
loc_network_match_country_code;
loc_network_new;
loc_network_new_from_string;
...
...
src/loc/database.h
View file @
82910b95
...
...
@@ -50,6 +50,7 @@ struct loc_database_enumerator* loc_database_enumerator_unref(struct loc_databas
int
loc_database_enumerator_set_string
(
struct
loc_database_enumerator
*
enumerator
,
const
char
*
string
);
int
loc_database_enumerator_set_country_code
(
struct
loc_database_enumerator
*
enumerator
,
const
char
*
country_code
);
int
loc_database_enumerator_set_asn
(
struct
loc_database_enumerator
*
enumerator
,
unsigned
int
asn
);
struct
loc_as
*
loc_database_enumerator_next_as
(
struct
loc_database_enumerator
*
enumerator
);
struct
loc_network
*
loc_database_enumerator_next_network
(
struct
loc_database_enumerator
*
enumerator
);
...
...
src/loc/network.h
View file @
82910b95
...
...
@@ -38,6 +38,7 @@ int loc_network_match_country_code(struct loc_network* network, const char* coun
uint32_t
loc_network_get_asn
(
struct
loc_network
*
network
);
int
loc_network_set_asn
(
struct
loc_network
*
network
,
uint32_t
asn
);
int
loc_network_match_asn
(
struct
loc_network
*
network
,
uint32_t
asn
);
#ifdef LIBLOC_PRIVATE
...
...
src/network.c
View file @
82910b95
...
...
@@ -324,6 +324,10 @@ LOC_EXPORT int loc_network_set_asn(struct loc_network* network, uint32_t asn) {
return
0
;
}
LOC_EXPORT
int
loc_network_match_asn
(
struct
loc_network
*
network
,
uint32_t
asn
)
{
return
network
->
asn
==
asn
;
}
LOC_EXPORT
int
loc_network_to_database_v0
(
struct
loc_network
*
network
,
struct
loc_database_network_v0
*
dbobj
)
{
// Add country code
for
(
unsigned
int
i
=
0
;
i
<
2
;
i
++
)
{
...
...
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