Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-SMF
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
Operations
Operations
Metrics
Environments
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
OpenXG
OpenXG-SMF
Commits
a02cd778
Commit
a02cd778
authored
Mar 30, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue for reading interface info
parent
fc314ef1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
src/common/utils/if.cpp
src/common/utils/if.cpp
+6
-3
No files found.
src/common/utils/if.cpp
View file @
a02cd778
...
...
@@ -183,7 +183,8 @@ int get_mtu_from_iface(const std::string& if_name, uint32_t& mtu) {
memset
(
&
ifr
,
0
,
sizeof
(
ifr
));
int
fd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
ifr
.
ifr_addr
.
sa_family
=
AF_INET
;
strncpy
(
ifr
.
ifr_name
,
(
const
char
*
)
if_name
.
c_str
(),
IFNAMSIZ
-
1
);
//strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ-1);
strcpy
(
ifr
.
ifr_name
,(
const
char
*
)
if_name
.
c_str
());
if
(
ioctl
(
fd
,
SIOCGIFMTU
,
&
ifr
))
{
close
(
fd
);
Logger
::
system
().
error
(
"Failed to probe %s MTU: error %s
\n
"
,
if_name
.
c_str
(),
strerror
(
errno
));
...
...
@@ -223,7 +224,8 @@ int get_inet_addr_infos_from_iface(const std::string& if_name, struct in_addr& i
memset
(
&
ifr
,
0
,
sizeof
(
ifr
));
ifr
.
ifr_addr
.
sa_family
=
AF_INET
;
strncpy
(
ifr
.
ifr_name
,
(
const
char
*
)
if_name
.
c_str
(),
IFNAMSIZ
-
1
);
//strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ-1);
strcpy
(
ifr
.
ifr_name
,(
const
char
*
)
if_name
.
c_str
());
if
(
ioctl
(
fd
,
SIOCGIFNETMASK
,
&
ifr
))
{
close
(
fd
);
Logger
::
system
().
error
(
"Failed to probe %s inet netmask: error %s
\n
"
,
if_name
.
c_str
(),
strerror
(
errno
));
...
...
@@ -240,7 +242,8 @@ int get_inet_addr_infos_from_iface(const std::string& if_name, struct in_addr& i
memset
(
&
ifr
,
0
,
sizeof
(
ifr
));
ifr
.
ifr_addr
.
sa_family
=
AF_INET
;
strncpy
(
ifr
.
ifr_name
,
(
const
char
*
)
if_name
.
c_str
(),
IFNAMSIZ
-
1
);
//strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ-1);
strcpy
(
ifr
.
ifr_name
,(
const
char
*
)
if_name
.
c_str
());
if
(
ioctl
(
fd
,
SIOCGIFMTU
,
&
ifr
))
{
Logger
::
system
().
error
(
"Failed to probe %s MTU: error %s
\n
"
,
if_name
.
c_str
(),
strerror
(
errno
));
}
else
{
...
...
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