summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2018-10-29 16:28:14 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2018-11-08 11:31:20 (GMT)
commitcf3d517763a3d74a2ec9fd6f7bdee8cbaee3550f (patch)
tree69e11e13ff2e5127d2cbfcc164be761cf104a1b2 /Swiften/LinkLocal
parent5ce9e19ef0744f530a797c30a82e9723eb7ea306 (diff)
downloadswift-cf3d517763a3d74a2ec9fd6f7bdee8cbaee3550f.zip
swift-cf3d517763a3d74a2ec9fd6f7bdee8cbaee3550f.tar.bz2
Consistently use unsigned short for network ports
Network ports are now consistently stored as unsigned shorts, apart from the options and user interface, where -1 is still used to denote the use of default ports. Test-Information: Unit tests pass on macOS 10.13 and Debian 9 On macOS: tested the UI with various proxy and manual ports, behaviour as expected. Change-Id: I7a65f40083022887aa30ed7b21eadc56d0c52be1
Diffstat (limited to 'Swiften/LinkLocal')
-rw-r--r--Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp4
-rw-r--r--Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h4
-rw-r--r--Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h6
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp5
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h4
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h24
-rw-r--r--Swiften/LinkLocal/DNSSD/DNSSDQuerier.h4
-rw-r--r--Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h6
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp6
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h6
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h6
-rw-r--r--Swiften/LinkLocal/LinkLocalService.h4
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceBrowser.cpp4
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceBrowser.h4
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceInfo.cpp10
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceInfo.h8
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp6
17 files changed, 66 insertions, 45 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp
index 1b79946..66b4ae8 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -25,7 +25,7 @@ std::shared_ptr<DNSSDBrowseQuery> AvahiQuerier::createBrowseQuery() {
return std::make_shared<AvahiBrowseQuery>(shared_from_this(), eventLoop);
}
-std::shared_ptr<DNSSDRegisterQuery> AvahiQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) {
+std::shared_ptr<DNSSDRegisterQuery> AvahiQuerier::createRegisterQuery(const std::string& name, unsigned short port, const ByteArray& info) {
return std::make_shared<AvahiRegisterQuery>(name, port, info, shared_from_this(), eventLoop);
}
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h
index 5dce19d..73dd11d 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -30,7 +30,7 @@ namespace Swift {
std::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
std::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const std::string& name, int port, const ByteArray& info);
+ const std::string& name, unsigned short port, const ByteArray& info);
std::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
const DNSSDServiceID&);
std::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h
index 68281d0..b780043 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -18,7 +18,7 @@ namespace Swift {
class AvahiRegisterQuery : public DNSSDRegisterQuery, public AvahiQuery {
public:
- AvahiRegisterQuery(const std::string& name, int port, const ByteArray& txtRecord, std::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), name(name), port(port), txtRecord(txtRecord), group(0) {
+ AvahiRegisterQuery(const std::string& name, unsigned short port, const ByteArray& txtRecord, std::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), name(name), port(port), txtRecord(txtRecord), group(0) {
}
void registerService();
@@ -50,7 +50,7 @@ namespace Swift {
private:
std::string name;
- int port;
+ unsigned short port;
ByteArray txtRecord;
AvahiEntryGroup* group;
};
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp
index 0906ffc..551421e 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <Swiften/Base/Algorithm.h>
+#include <Swiften/Base/Log.h>
#include <Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h>
#include <Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h>
#include <Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h>
@@ -36,7 +37,7 @@ std::shared_ptr<DNSSDBrowseQuery> BonjourQuerier::createBrowseQuery() {
return std::make_shared<BonjourBrowseQuery>(shared_from_this(), eventLoop);
}
-std::shared_ptr<DNSSDRegisterQuery> BonjourQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) {
+std::shared_ptr<DNSSDRegisterQuery> BonjourQuerier::createRegisterQuery(const std::string& name, unsigned short port, const ByteArray& info) {
return std::make_shared<BonjourRegisterQuery>(name, port, info, shared_from_this(), eventLoop);
}
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h
index 77326bc..6af1c1f 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -25,7 +25,7 @@ namespace Swift {
std::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
std::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const std::string& name, int port, const ByteArray& info);
+ const std::string& name, unsigned short port, const ByteArray& info);
std::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
const DNSSDServiceID&);
std::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h
index 8b2e955..9eb8cd9 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,12 +20,21 @@ namespace Swift {
class BonjourRegisterQuery : public DNSSDRegisterQuery, public BonjourQuery {
public:
- BonjourRegisterQuery(const std::string& name, int port, const ByteArray& txtRecord, std::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) {
+ BonjourRegisterQuery(const std::string& name, unsigned short port, const ByteArray& txtRecord, std::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) {
+ unsigned short recordSize = 0;
+ try {
+ recordSize = boost::numeric_cast<unsigned short>(txtRecord.size());
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ SWIFT_LOG(warning) << "Bonjour TXT record is too long (" << txtRecord.size() << " bytes), not registring service" << std::endl;
+ return;
+ }
DNSServiceErrorType result = DNSServiceRegister(
- &sdRef, 0, 0, name.c_str(), "_presence._tcp", nullptr, nullptr, boost::numeric_cast<unsigned short>(port),
- boost::numeric_cast<unsigned short>(txtRecord.size()), vecptr(txtRecord),
+ &sdRef, 0, 0, name.c_str(), "_presence._tcp", nullptr, nullptr, port,
+ recordSize, vecptr(txtRecord),
&BonjourRegisterQuery::handleServiceRegisteredStatic, this);
if (result != kDNSServiceErr_NoError) {
+ SWIFT_LOG(warning) << "Failed to register Bonjour service" << std::endl;
sdRef = nullptr;
}
}
@@ -45,7 +54,12 @@ namespace Swift {
void updateServiceInfo(const ByteArray& txtRecord) {
std::lock_guard<std::mutex> lock(sdRefMutex);
- DNSServiceUpdateRecord(sdRef, nullptr, 0, boost::numeric_cast<unsigned short>(txtRecord.size()), vecptr(txtRecord), 0);
+ try {
+ DNSServiceUpdateRecord(sdRef, nullptr, 0, boost::numeric_cast<unsigned short>(txtRecord.size()), vecptr(txtRecord), 0);
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ SWIFT_LOG(warning) << "Bonjour TXT record is too long (" << txtRecord.size() << " bytes), not updating service record" << std::endl;
+ }
}
private:
diff --git a/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h
index 8f3c3ec..3924c05 100644
--- a/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -26,7 +26,7 @@ namespace Swift {
virtual std::shared_ptr<DNSSDBrowseQuery> createBrowseQuery() = 0;
virtual std::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const std::string& name, int port, const ByteArray& info) = 0;
+ const std::string& name, unsigned short port, const ByteArray& info) = 0;
virtual std::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
const DNSSDServiceID&) = 0;
virtual std::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
diff --git a/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h
index b55447a..6416d69 100644
--- a/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h
+++ b/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -16,11 +16,11 @@ namespace Swift {
class DNSSDResolveServiceQuery {
public:
struct Result {
- Result(const std::string& fullName, const std::string& host, int port, const ByteArray& info) :
+ Result(const std::string& fullName, const std::string& host, unsigned short port, const ByteArray& info) :
fullName(fullName), host(host), port(port), info(info) {}
std::string fullName;
std::string host;
- int port;
+ unsigned short port;
ByteArray info;
};
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
index c17f8b2..3381a26 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -32,7 +32,7 @@ std::shared_ptr<DNSSDBrowseQuery> FakeDNSSDQuerier::createBrowseQuery() {
return std::make_shared<FakeDNSSDBrowseQuery>(shared_from_this());
}
-std::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) {
+std::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const std::string& name, unsigned short port, const ByteArray& info) {
return std::make_shared<FakeDNSSDRegisterQuery>(name, port, info, shared_from_this());
}
@@ -105,7 +105,7 @@ void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResol
}
}
-bool FakeDNSSDQuerier::isServiceRegistered(const std::string& name, int port, const ByteArray& info) {
+bool FakeDNSSDQuerier::isServiceRegistered(const std::string& name, unsigned short port, const ByteArray& info) {
for (const auto& query : getQueries<FakeDNSSDRegisterQuery>()) {
if (query->name == name && query->port == port && query->info == info) {
return true;
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
index 5d4fefd..07cb75c 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2017 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -39,7 +39,7 @@ namespace Swift {
std::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
std::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const std::string& name, int port, const ByteArray& info);
+ const std::string& name, unsigned short port, const ByteArray& info);
std::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
const DNSSDServiceID&);
std::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
@@ -51,7 +51,7 @@ namespace Swift {
void addService(const DNSSDServiceID& id);
void removeService(const DNSSDServiceID& id);
void setServiceInfo(const DNSSDServiceID& id, const DNSSDResolveServiceQuery::Result& info);
- bool isServiceRegistered(const std::string& name, int port, const ByteArray& info);
+ bool isServiceRegistered(const std::string& name, unsigned short port, const ByteArray& info);
void setAddress(const std::string& hostname, boost::optional<HostAddress> address);
void setBrowseError();
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h
index 7478841..ee6bb92 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,7 +17,7 @@ namespace Swift {
class FakeDNSSDRegisterQuery : public DNSSDRegisterQuery, public FakeDNSSDQuery {
public:
- FakeDNSSDRegisterQuery(const std::string& name, int port, const ByteArray& info, std::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) {
+ FakeDNSSDRegisterQuery(const std::string& name, unsigned short port, const ByteArray& info, std::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) {
}
void registerService() {
@@ -33,7 +33,7 @@ namespace Swift {
}
std::string name;
- int port;
+ unsigned short port;
ByteArray info;
};
}
diff --git a/Swiften/LinkLocal/LinkLocalService.h b/Swiften/LinkLocal/LinkLocalService.h
index 9b0e2ab..c51f890 100644
--- a/Swiften/LinkLocal/LinkLocalService.h
+++ b/Swiften/LinkLocal/LinkLocalService.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -31,7 +31,7 @@ namespace Swift {
return id.getName();
}
- int getPort() const {
+ unsigned short getPort() const {
return info.port;
}
diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
index b79f184..b3328cd 100644
--- a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
+++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -65,7 +65,7 @@ bool LinkLocalServiceBrowser::isRegistered() const {
return !!registerQuery;
}
-void LinkLocalServiceBrowser::registerService(const std::string& name, int port, const LinkLocalServiceInfo& info) {
+void LinkLocalServiceBrowser::registerService(const std::string& name, unsigned short port, const LinkLocalServiceInfo& info) {
assert(!registerQuery);
registerQuery = querier->createRegisterQuery(name, port, info.toTXTRecord());
registerQuery->onRegisterFinished.connect(
diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.h b/Swiften/LinkLocal/LinkLocalServiceBrowser.h
index c59a4d0..bfcfc07 100644
--- a/Swiften/LinkLocal/LinkLocalServiceBrowser.h
+++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -35,7 +35,7 @@ namespace Swift {
void registerService(
const std::string& name,
- int port,
+ unsigned short port,
const LinkLocalServiceInfo& info = LinkLocalServiceInfo());
void updateService(
const LinkLocalServiceInfo& info = LinkLocalServiceInfo());
diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
index 771251a..102b7f3 100644
--- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
+++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2013 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -82,7 +82,13 @@ LinkLocalServiceInfo LinkLocalServiceInfo::createFromTXTRecord(const ByteArray&
info.setNick(entry.second);
}
else if (entry.first == "port.p2pj") {
- info.setPort(boost::lexical_cast<int>(entry.second));
+ try {
+ info.setPort(boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(entry.second)));
+ }
+ catch (const boost::bad_lexical_cast&) {
+ }
+ catch (const boost::numeric::bad_numeric_cast&) {
+ }
}
else if (entry.first == "status") {
if (entry.second == "away") {
diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.h b/Swiften/LinkLocal/LinkLocalServiceInfo.h
index 9f15c6e..eb65706 100644
--- a/Swiften/LinkLocal/LinkLocalServiceInfo.h
+++ b/Swiften/LinkLocal/LinkLocalServiceInfo.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -43,8 +43,8 @@ namespace Swift {
Status getStatus() const { return status; }
void setStatus(Status s) { status = s; }
- boost::optional<int> getPort() const { return port; }
- void setPort(int p) { port = p; }
+ boost::optional<unsigned short> getPort() const { return port; }
+ void setPort(unsigned short p) { port = p; }
ByteArray toTXTRecord() const;
@@ -62,6 +62,6 @@ namespace Swift {
std::string message;
std::string nick;
Status status;
- boost::optional<int> port;
+ boost::optional<unsigned short> port;
};
}
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
index 85ae537..ab1ee0c 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -53,7 +53,7 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(!connectError);
CPPUNIT_ASSERT(connection->connectedTo);
CPPUNIT_ASSERT_EQUAL(std::string(connection->connectedTo->getAddress().toString()), std::string("192.168.1.1"));
- CPPUNIT_ASSERT_EQUAL(connection->connectedTo->getPort(), 1234);
+ CPPUNIT_ASSERT_EQUAL(connection->connectedTo->getPort(), static_cast<unsigned short>(1234));
}
void testConnect_UnableToResolve() {
@@ -114,7 +114,7 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture {
}
private:
- std::shared_ptr<LinkLocalConnector> createConnector(const std::string& hostname, int port) {
+ std::shared_ptr<LinkLocalConnector> createConnector(const std::string& hostname, unsigned short port) {
LinkLocalService service(
DNSSDServiceID("myname", "local."),
DNSSDResolveServiceQuery::Result(