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
723a9690
Commit
723a9690
authored
Oct 10, 2024
by
郭峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-1007488' into 'release'
修改ping命令-07 See merge request
!46
parents
6b97cdf9
6139d6d8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
14 deletions
+30
-14
Common.h
+1
-4
NonConnectedCameraHandle.cpp
+6
-10
VidesData.h
+23
-0
No files found.
Common.h
View file @
723a9690
...
@@ -80,11 +80,8 @@ public:
...
@@ -80,11 +80,8 @@ public:
//确定当前网络接口
//确定当前网络接口
void
determine_interface
(
char
*
interface
);
void
determine_interface
(
char
*
interface
);
QString
GetLocalMac
(
const
char
*
eth_inf
);
// 获取本机mac
QString
GetLocalNetMask
(
const
char
*
eth_inf
);
//获取本机mask
QString
GetLocalGateWay
();
//获取本机gateway
QString
GetLocalGateWay
();
//获取本机gateway
bool
pingAddress
(
const
QString
&
address
)
;
bool
pingAddress
(
const
QString
&
address
)
;
...
...
NonConnectedCameraHandle.cpp
View file @
723a9690
...
@@ -29,21 +29,17 @@ bool NonConnectedCameraHandle::changeCameraIp(vides_data::localDevice &device){
...
@@ -29,21 +29,17 @@ bool NonConnectedCameraHandle::changeCameraIp(vides_data::localDevice &device){
// 确定当前网络接口
// 确定当前网络接口
instace
.
determine_interface
(
interface
);
instace
.
determine_interface
(
interface
);
// 获取网络信息
QString
localMac
=
instace
.
GetLocalMac
(
interface
);
QString
subnetMask
;
QString
subnetMask
=
instace
.
GetLocalNetMask
(
interface
);
bool
sub
=
vides_data
::
GetSubnetMask
(
subnetMask
);
QString
gateway
=
instace
.
GetLocalGateWay
();
QString
gateway
=
instace
.
GetLocalGateWay
();
qInfo
()
<<
QString
(
"SN(%1): 获取本地MAC:%2,subnetMask:%3,gateway:%4"
).
arg
(
device
.
sSn
).
arg
(
localMac
)
.
arg
(
subnetMask
).
arg
(
gateway
);
if
(
localMac
.
length
()
==
0
&&
subnetMask
.
length
()
==
0
&&
gateway
.
length
()
==
0
)
{
if
(
!
sub
&&
gateway
.
length
()
==
0
)
{
qInfo
()
<<
QString
(
"SN(%1): 获取本地MAC失败"
).
arg
(
device
.
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 获取本地MAC失败"
).
arg
(
device
.
sSn
);
return
false
;
return
false
;
}
}
QByteArray
&&
byJson
=
localMac
.
toUtf8
();
const
char
*
mac
=
byJson
.
data
();
QByteArray
&&
byJsonIp
=
device
.
reachableIp
.
toUtf8
();
QByteArray
&&
byJsonIp
=
device
.
reachableIp
.
toUtf8
();
const
char
*
charIp
=
byJsonIp
.
data
();
const
char
*
charIp
=
byJsonIp
.
data
();
...
@@ -131,7 +127,7 @@ bool NonConnectedCameraHandle::changeCameraIp(vides_data::localDevice &device){
...
@@ -131,7 +127,7 @@ bool NonConnectedCameraHandle::changeCameraIp(vides_data::localDevice &device){
strcpy
(
devInfo
.
HostName
,
pDevice
->
HostName
);
strcpy
(
devInfo
.
HostName
,
pDevice
->
HostName
);
devInfo
.
HttpPort
=
pDevice
->
HttpPort
;
devInfo
.
HttpPort
=
pDevice
->
HttpPort
;
strcpy
(
devInfo
.
LocalMac
,
mac
);
//strcpy(devInfo.LocalMac, pDevice
);
devInfo
.
MaxBps
=
pDevice
->
MaxBps
;
devInfo
.
MaxBps
=
pDevice
->
MaxBps
;
devInfo
.
MaxConn
=
pDevice
->
MaxConn
;
devInfo
.
MaxConn
=
pDevice
->
MaxConn
;
devInfo
.
MonMode
=
pDevice
->
MonMode
;
devInfo
.
MonMode
=
pDevice
->
MonMode
;
...
...
VidesData.h
View file @
723a9690
...
@@ -440,6 +440,29 @@ inline bool isInSameSubnet(const QString &ip1, const QString &ip2, const QString
...
@@ -440,6 +440,29 @@ inline bool isInSameSubnet(const QString &ip1, const QString &ip2, const QString
// 比较结果
// 比较结果
return
result1
==
result2
;
return
result1
==
result2
;
}
}
// 获取子网掩码
inline
bool
GetSubnetMask
(
QString
&
subnetMask
)
{
QList
<
QNetworkInterface
>
interfaces
=
QNetworkInterface
::
allInterfaces
();
foreach
(
QNetworkInterface
interface
,
interfaces
)
{
if
(
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsUp
)
&&
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsRunning
)
&&
!
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsLoopBack
))
{
QList
<
QNetworkAddressEntry
>
addressEntries
=
interface
.
addressEntries
();
foreach
(
QNetworkAddressEntry
entry
,
addressEntries
)
{
if
(
entry
.
ip
().
protocol
()
==
QAbstractSocket
::
IPv4Protocol
)
{
subnetMask
=
entry
.
netmask
().
toString
();
return
true
;
// 成功获取子网掩码
}
}
}
}
// 如果没有找到合适的接口或子网掩码
subnetMask
=
"Unknown"
;
return
false
;
}
inline
bool
pingAddress
(
const
QString
&
address
)
{
inline
bool
pingAddress
(
const
QString
&
address
)
{
QProcess
cmd
;
QProcess
cmd
;
...
...
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