Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
5f9bab83
Commit
5f9bab83
authored
Oct 07, 2022
by
GAO Bin
Browse files
mem_switch: fix problem when creating static mac table
parent
9a74fecd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
sims/net/mem_switch/mem_switch.cc
sims/net/mem_switch/mem_switch.cc
+17
-7
No files found.
sims/net/mem_switch/mem_switch.cc
View file @
5f9bab83
...
...
@@ -45,7 +45,7 @@ extern "C" {
#include <simbricks/mem/memop.h>
};
//#define NETSWITCH_DEBUG
//
#define NETSWITCH_DEBUG
#define NETSWITCH_STAT
struct
SimbricksBaseIfParams
netParams
;
...
...
@@ -569,18 +569,28 @@ int main(int argc, char *argv[]) {
auto
&
port
=
*
ports
[
port_i
];
std
::
string
sockpath
=
port
.
path_
;
if
(
sockpath
.
find
(
netmem_name
)
!=
std
::
string
::
npos
){
printf
(
"port id for %s is %lu
\n
"
,
netmem_name
.
c_str
(),
port_i
);
uint8_t
*
temp
=
(
uint8_t
*
)
malloc
(
6
);
memcpy
(
temp
,
(
const
uint8_t
*
)
ent
.
node_mac
.
ether_addr_octet
,
6
);
MAC
node_mac
((
const
uint8_t
*
)
temp
);
bool
exisiting
=
false
;
for
(
auto
iter
=
mac_table
.
begin
();
iter
!=
mac_table
.
end
();
++
iter
)
{
if
(
iter
->
first
==
node_mac
){
exisiting
=
true
;
break
;
}
}
if
(
exisiting
){
break
;
}
else
{
printf
(
"port id for %s is %lu
\n
"
,
netmem_name
.
c_str
(),
port_i
);
mac_table
.
insert
({
node_mac
,
port_i
});
printf
(
"mac_8: %X:%X:%X:%X:%X:%X
\n
"
,
node_mac
.
data
[
0
],
node_mac
.
data
[
1
],
node_mac
.
data
[
2
],
node_mac
.
data
[
3
],
node_mac
.
data
[
4
],
node_mac
.
data
[
5
]);
netmem_idx
++
;
}
}
}
netmem_idx
++
;
break
;
default:
...
...
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