Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCHNetChecker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
borsitsb
SCHNetChecker
Commits
5add3e78
Commit
5add3e78
authored
9 years ago
by
borsitsb
Browse files
Options
Downloads
Patches
Plain Diff
added network commands research
parent
702b4709
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/Diagnostic.hpp
+20
-10
20 additions, 10 deletions
include/Diagnostic.hpp
with
20 additions
and
10 deletions
include/Diagnostic.hpp
+
20
−
10
View file @
5add3e78
...
...
@@ -5,6 +5,7 @@
#include
<QRegExp>
#include
<QCoreApplication>
#include
<QtNetwork/QNetworkInterface>
#include
<QSysInfo>
#ifndef DIAGNOSTIC_HPP
#define DIAGNOSTIC_HPP
...
...
@@ -14,31 +15,40 @@ class Diagnostic {
typedef
QString
(
*
diagFn_t
)();
public:
static
const
int
funcsLen
=
3
;
static
const
int
funcsLen
=
4
;
diagFn_t
funcs
[
funcsLen
];
Diagnostic
(){
funcs
[
0
]
=
getRoutingInfo
;
funcs
[
1
]
=
getPingGateway
;
funcs
[
2
]
=
getInterfaceInfo
;
funcs
[
1
]
=
getOsInfo
;
funcs
[
2
]
=
getPingGateway
;
funcs
[
3
]
=
getInterfaceInfo
;
}
static
QString
getOsInfo
()
{
// Windows: http://www.windows-commandline.com/find-windows-os-version-from-command/
// Linux: http://superuser.com/questions/11008/how-do-i-find-out-what-version-of-linux-im-running
// I think the best way on linux is: uname -a
// Mac: http://superuser.com/questions/75166/how-to-find-out-mac-os-x-version-from-terminal
// The best way on Mac: sw_vers
return
QString
(
"- - - OS version - - -
\n
OS version"
);
}
static
QString
getRoutingInfo
(){
// Useful commands: https://kb.wisc.edu/ns/page.php?id=12364
FILE
*
cmdHandle
;
QString
ipAddr
(
"- - -
Default Gateway
- - -
\n
"
);
QString
ipAddr
(
"- - -
Routing tables
- - -
\n
"
);
#if defined( Q_OS_WIN )
// original command: route print -4 | findstr /r "[^0-9]0\.0\.0\.0"
cmdHandle
=
popen
(
"
route print -4 | findstr /r
\"
[^0-9]0
\\
.0
\\
.0
\\
.0
\"
"
,
"r"
"
netsh interface ipv4 show route
"
,
"r"
);
#elif defined ( Q_OS_LINUX )
// a guess: netstat -rn | grep "^0\.0\.0\.0" | awk '{print $2}'
// w/o awk: netstat -rn | sed -rn 's/^0\.0\.0\.0\s+([^ ]+).*/\1/p'
cmdHandle
=
popen
(
"netstat -
rn | sed -rn 's/^0\.0\.0\.0\s+([^ ]+).*/
\1
/p'
"
,
"r"
"netstat -
A inet -rn
"
,
"r"
);
#else
#error "
W
e do not support
gateway command for
this OS
.
"
#error "
Sorry, w
e do not support this OS
!
"
#endif
const
int
BUFFSIZE
=
256
;
char
buffer
[
BUFFSIZE
];
...
...
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