Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gamera_videos_no_ui
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liusq
gamera_videos_no_ui
Commits
b4c5a797
Commit
b4c5a797
authored
Oct 10, 2024
by
郭峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-1007488' into 'release'
修改ping命令-08 See merge request
!47
parents
723a9690
b7a8a92b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
59 deletions
+0
-59
Common.cpp
+0
-59
No files found.
Common.cpp
View file @
b4c5a797
...
...
@@ -334,65 +334,6 @@ void Common::determine_interface(char *interface) {
freeifaddrs
(
ifaddr
);
}
QString
Common
::
GetLocalMac
(
const
char
*
eth_inf
)
{
struct
ifreq
ifr
;
int
sd
;
char
mac
[
MAC_SIZE
];
// local buffer for mac address
bzero
(
&
ifr
,
sizeof
(
struct
ifreq
));
if
((
sd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
<
0
)
{
qDebug
()
<<
"get"
<<
eth_inf
<<
"mac address socket create error"
;
return
QString
();
}
strncpy
(
ifr
.
ifr_name
,
eth_inf
,
sizeof
(
ifr
.
ifr_name
)
-
1
);
if
(
ioctl
(
sd
,
SIOCGIFHWADDR
,
&
ifr
)
<
0
)
{
qDebug
()
<<
"get"
<<
eth_inf
<<
"mac address error"
;
close
(
sd
);
return
QString
();
}
snprintf
(
mac
,
MAC_SIZE
,
"%02x:%02x:%02x:%02x:%02x:%02x"
,
(
unsigned
char
)
ifr
.
ifr_hwaddr
.
sa_data
[
0
],
(
unsigned
char
)
ifr
.
ifr_hwaddr
.
sa_data
[
1
],
(
unsigned
char
)
ifr
.
ifr_hwaddr
.
sa_data
[
2
],
(
unsigned
char
)
ifr
.
ifr_hwaddr
.
sa_data
[
3
],
(
unsigned
char
)
ifr
.
ifr_hwaddr
.
sa_data
[
4
],
(
unsigned
char
)
ifr
.
ifr_hwaddr
.
sa_data
[
5
]);
close
(
sd
);
return
QString
(
mac
);
// convert C-string to QString
}
QString
Common
::
GetLocalNetMask
(
const
char
*
eth_inf
)
{
int
sock_netmask
;
struct
ifreq
ifr_mask
;
struct
sockaddr_in
*
net_mask
;
sock_netmask
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
sock_netmask
==
-
1
)
{
perror
(
"create socket failure...GetLocalNetMask
\n
"
);
return
QString
();
}
memset
(
&
ifr_mask
,
0
,
sizeof
(
ifr_mask
));
strncpy
(
ifr_mask
.
ifr_name
,
eth_inf
,
sizeof
(
ifr_mask
.
ifr_name
)
-
1
);
if
((
ioctl
(
sock_netmask
,
SIOCGIFNETMASK
,
&
ifr_mask
))
<
0
)
{
qDebug
()
<<
"netmask ioctl error"
;
close
(
sock_netmask
);
return
QString
();
}
net_mask
=
(
struct
sockaddr_in
*
)
&
(
ifr_mask
.
ifr_netmask
);
QString
netmaskAddr
=
QString
(
inet_ntoa
(
net_mask
->
sin_addr
));
// Convert to QString
close
(
sock_netmask
);
return
netmaskAddr
;
}
QString
Common
::
GetLocalGateWay
()
{
FILE
*
fp
;
char
buf
[
512
];
...
...
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