Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
a76dd63b
Commit
a76dd63b
authored
Apr 16, 2018
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge conflict fix
parent
8b8a55c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
57 deletions
+15
-57
UDPLink.cc
src/comm/UDPLink.cc
+15
-57
No files found.
src/comm/UDPLink.cc
View file @
a76dd63b
...
...
@@ -160,7 +160,6 @@ QString UDPLink::getName() const
void
UDPLink
::
_writeBytes
(
const
QByteArray
data
)
{
<<<<<<<
HEAD
if
(
!
_socket
)
return
;
// Send to all manually targeted systems
...
...
@@ -168,37 +167,6 @@ void UDPLink::_writeBytes(const QByteArray data)
// Skip it if it's part of the session clients below
if
(
!
contains_target
(
_sessionTargets
,
target
->
address
,
target
->
port
))
{
_writeDataGram
(
data
,
target
);
=======
if
(
_socket
)
{
QStringList
goneHosts
;
// Send to all connected systems
QString
host
;
int
port
;
if
(
_udpConfig
->
firstHost
(
host
,
port
))
{
do
{
QHostAddress
currentHost
(
host
);
if
(
_socket
->
writeDatagram
(
data
,
currentHost
,
(
quint16
)
port
)
<
0
)
{
// This host is gone. Add to list to be removed
// We should keep track of hosts that were manually added (static) and
// hosts that were added because we heard from them (dynamic). Only
// dynamic hosts should be removed and even then, after a few tries, not
// the first failure. In the mean time, we don't remove anything.
if
(
REMOVE_GONE_HOSTS
)
{
goneHosts
.
append
(
host
);
}
}
else
{
// Only log rate if data actually got sent. Not sure about this as
// "host not there" takes time too regardless of size of data. In fact,
// 1 byte or "UDP frame size" bytes are the same as that's the data
// unit sent by UDP.
_logOutputDataRate
(
data
.
size
(),
QDateTime
::
currentMSecsSinceEpoch
());
}
}
while
(
_udpConfig
->
nextHost
(
host
,
port
));
//-- Remove hosts that are no longer there
foreach
(
const
QString
&
ghost
,
goneHosts
)
{
_udpConfig
->
removeHost
(
ghost
);
}
>>>>>>>
b4f4085c6733b934358b00389d734600eab87bf7
}
}
// Send to all connected systems
...
...
@@ -226,31 +194,23 @@ void UDPLink::_writeDataGram(const QByteArray data, const UDPCLient* target)
void
UDPLink
::
readBytes
()
{
if
(
_socket
)
{
QByteArray
databuffer
;
while
(
_socket
->
hasPendingDatagrams
())
{
QByteArray
datagram
;
datagram
.
resize
(
_socket
->
pendingDatagramSize
());
QHostAddress
sender
;
quint16
senderPort
;
_socket
->
readDatagram
(
datagram
.
data
(),
datagram
.
size
(),
&
sender
,
&
senderPort
);
databuffer
.
append
(
datagram
);
//-- Wait a bit before sending it over
if
(
databuffer
.
size
()
>
10
*
1024
)
{
emit
bytesReceived
(
this
,
databuffer
);
databuffer
.
clear
();
}
_logInputDataRate
(
datagram
.
length
(),
QDateTime
::
currentMSecsSinceEpoch
());
// TODO This doesn't validade the sender. Anything sending UDP packets to this port gets
// added to the list and will start receiving datagrams from here. Even a port scanner
// would trigger this.
// Add host to broadcast list if not yet present, or update its port
_udpConfig
->
addHost
(
sender
.
toString
(),
(
int
)
senderPort
);
}
//-- Send whatever is left
if
(
databuffer
.
size
())
{
return
;
}
QByteArray
databuffer
;
while
(
_socket
->
hasPendingDatagrams
())
{
QByteArray
datagram
;
datagram
.
resize
(
_socket
->
pendingDatagramSize
());
QHostAddress
sender
;
quint16
senderPort
;
_socket
->
readDatagram
(
datagram
.
data
(),
datagram
.
size
(),
&
sender
,
&
senderPort
);
databuffer
.
append
(
datagram
);
//-- Wait a bit before sending it over
if
(
databuffer
.
size
()
>
10
*
1024
)
{
emit
bytesReceived
(
this
,
databuffer
);
databuffer
.
clear
();
}
<<<<<<<
HEAD
_logInputDataRate
(
datagram
.
length
(),
QDateTime
::
currentMSecsSinceEpoch
());
// TODO: This doesn't validade the sender. Anything sending UDP packets to this port gets
// added to the list and will start receiving datagrams from here. Even a port scanner
...
...
@@ -269,8 +229,6 @@ void UDPLink::readBytes()
//-- Send whatever is left
if
(
databuffer
.
size
())
{
emit
bytesReceived
(
this
,
databuffer
);
=======
>>>>>>>
b4f4085c6733b934358b00389d734600eab87bf7
}
}
...
...
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