Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mcproxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Fork
mcproxy
Commits
3f07228a
Commit
3f07228a
authored
5 years ago
by
Jonas Höglund
Browse files
Options
Downloads
Patches
Plain Diff
Fix parsing several interfaces
parent
b5d486fe
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#222
canceled
5 years ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mcproxy/include/parser/interface.hpp
+1
-0
1 addition, 0 deletions
mcproxy/include/parser/interface.hpp
mcproxy/src/parser/configuration.cpp
+40
-27
40 additions, 27 deletions
mcproxy/src/parser/configuration.cpp
mcproxy/src/parser/interface.cpp
+6
-0
6 additions, 0 deletions
mcproxy/src/parser/interface.cpp
with
47 additions
and
27 deletions
mcproxy/include/parser/interface.hpp
+
1
−
0
View file @
3f07228a
...
...
@@ -246,6 +246,7 @@ private:
public:
inst_def_set
();
bool
insert
(
const
std
::
shared_ptr
<
instance_definition
>&
id
);
bool
erase
(
const
std
::
shared_ptr
<
instance_definition
>&
id
);
const_iterator
find
(
const
std
::
string
&
instance_name
)
const
{
return
m_instance_def_set
.
find
(
std
::
make_shared
<
instance_definition
>
(
instance_name
));
...
...
This diff is collapsed.
Click to expand it.
mcproxy/src/parser/configuration.cpp
+
40
−
27
View file @
3f07228a
...
...
@@ -195,34 +195,47 @@ void configuration::initalize_interfaces()
HC_LOG_TRACE
(
""
);
unsigned
int
if_index
;
for
(
auto
&
inst
:
m_inst_def_set
)
{
auto
result
=
std
::
make_shared
<
interfaces
>
(
get_addr_family
(
m_gmp
),
m_reset_reverse_path_filter
);
auto
add
=
[
&
](
const
std
::
shared_ptr
<
interface
>&
interf
)
{
if_index
=
interfaces
::
get_if_index
(
interf
->
get_if_name
());
if
(
if_index
==
0
)
{
HC_LOG_ERROR
(
"interface "
<<
interf
->
get_if_name
()
<<
" not found"
);
throw
"unknown interface"
;
}
if
(
!
result
->
add_interface
(
if_index
))
{
throw
"failed to add interface"
;
}
};
for
(
auto
&
downstream
:
inst
->
get_downstreams
())
{
add
(
downstream
);
}
for
(
auto
&
upstream
:
inst
->
get_upstreams
())
{
add
(
upstream
);
}
if
(
!
m_interfaces_map
.
insert
(
std
::
pair
<
std
::
string
,
std
::
shared_ptr
<
interfaces
>>
(
inst
->
get_instance_name
(),
result
)).
second
)
{
HC_LOG_ERROR
(
"proxy instance "
<<
inst
->
get_instance_name
()
<<
" already exists"
);
throw
"failed to add instance"
;
}
auto
def_set
=
m_inst_def_set
;
auto
result
=
std
::
make_shared
<
interfaces
>
(
get_addr_family
(
m_gmp
),
m_reset_reverse_path_filter
);
auto
add
=
[
&
](
const
std
::
shared_ptr
<
interface
>&
interf
)
{
if_index
=
interfaces
::
get_if_index
(
interf
->
get_if_name
());
if
(
if_index
==
0
)
{
HC_LOG_ERROR
(
"interface "
<<
interf
->
get_if_name
()
<<
" not found"
);
throw
"unknown interface"
;
}
if
(
!
result
->
add_interface
(
if_index
))
{
throw
"failed to add interface"
;
}
};
for
(
auto
&
inst
:
def_set
)
{
try
{
for
(
auto
&
downstream
:
inst
->
get_downstreams
())
{
add
(
downstream
);
}
for
(
auto
&
upstream
:
inst
->
get_upstreams
())
{
add
(
upstream
);
}
if
(
!
m_interfaces_map
.
insert
(
std
::
pair
<
std
::
string
,
std
::
shared_ptr
<
interfaces
>>
(
inst
->
get_instance_name
(),
result
)).
second
)
{
HC_LOG_ERROR
(
"proxy instance "
<<
inst
->
get_instance_name
()
<<
" already exists"
);
throw
"failed to add instance"
;
}
}
catch
(
const
char
*
s
)
{
m_inst_def_set
.
erase
(
inst
);
continue
;
}
}
if
(
m_inst_def_set
.
size
()
==
0
)
{
throw
"no valid interfaces found"
;
}
}
#ifdef DEBUG_MODE
...
...
This diff is collapsed.
Click to expand it.
mcproxy/src/parser/interface.cpp
+
6
−
0
View file @
3f07228a
...
...
@@ -595,6 +595,12 @@ bool inst_def_set::insert(const std::shared_ptr<instance_definition>& id)
return
m_instance_def_set
.
insert
(
id
).
second
;
}
bool
inst_def_set
::
erase
(
const
std
::
shared_ptr
<
instance_definition
>&
id
)
{
HC_LOG_TRACE
(
""
);
return
m_instance_def_set
.
erase
(
id
);
}
unsigned
int
inst_def_set
::
size
()
const
{
HC_LOG_TRACE
(
""
);
...
...
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