mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1167210: Replace |union sockaddr_any| with |struct sockaddr_storage|, r=kmachulis
Both types, |union sockaddr_any| and |struct sockaddr_storage|, provide a sockaddr type that can hold any address. The latter is standardized by POSIX, so we prefer it.
This commit is contained in:
parent
41d5f504bf
commit
621428ac80
@ -7,6 +7,7 @@
|
||||
|
||||
#include "BluetoothDaemonConnector.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/un.h>
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
#include "BluetoothUnixSocketConnector.h"
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/l2cap.h>
|
||||
#include <bluetooth/rfcomm.h>
|
||||
#include <bluetooth/sco.h>
|
||||
|
@ -7,6 +7,7 @@
|
||||
#ifndef mozilla_dom_bluetooth_BluetoothUnixSocketConnector_h
|
||||
#define mozilla_dom_bluetooth_BluetoothUnixSocketConnector_h
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include "BluetoothCommon.h"
|
||||
#include "mozilla/ipc/UnixSocketConnector.h"
|
||||
|
||||
|
@ -226,8 +226,8 @@ public:
|
||||
//
|
||||
|
||||
nsresult Accept(int aFd,
|
||||
const union sockaddr_any* aAddr,
|
||||
socklen_t aAddrLen) override;
|
||||
const struct sockaddr* aAddress,
|
||||
socklen_t aAddressLength) override;
|
||||
|
||||
// Methods for |DataSocketIO|
|
||||
//
|
||||
@ -336,8 +336,8 @@ BluetoothDaemonConnectionIO::OnError(const char* aFunction, int aErrno)
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonConnectionIO::Accept(int aFd,
|
||||
const union sockaddr_any* aAddr,
|
||||
socklen_t aAddrLen)
|
||||
const struct sockaddr* aAddress,
|
||||
socklen_t aAddressLength)
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
|
||||
MOZ_ASSERT(GetConnectionStatus() == SOCKET_IS_CONNECTING);
|
||||
|
@ -8,33 +8,11 @@
|
||||
#define mozilla_ipc_UnixSocketWatcher_h
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef MOZ_B2G_BT_BLUEZ
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/sco.h>
|
||||
#include <bluetooth/l2cap.h>
|
||||
#include <bluetooth/rfcomm.h>
|
||||
#endif
|
||||
#include "UnixFdWatcher.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
union sockaddr_any {
|
||||
sockaddr_storage storage; // address-family only
|
||||
sockaddr_un un;
|
||||
sockaddr_in in;
|
||||
sockaddr_in6 in6;
|
||||
#ifdef MOZ_B2G_BT_BLUEZ
|
||||
sockaddr_sco sco;
|
||||
sockaddr_rc rc;
|
||||
sockaddr_l2 l2;
|
||||
#endif
|
||||
// ... others
|
||||
};
|
||||
|
||||
class UnixSocketWatcher : public UnixFdWatcher
|
||||
{
|
||||
public:
|
||||
|
@ -14,7 +14,6 @@ namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
class UnixSocketConnector;
|
||||
union sockaddr_any;
|
||||
|
||||
/*
|
||||
* |ConnectionOrientedSocketIO| and |ConnectionOrientedSocket| define
|
||||
@ -28,8 +27,8 @@ public:
|
||||
virtual ~ConnectionOrientedSocketIO();
|
||||
|
||||
virtual nsresult Accept(int aFd,
|
||||
const union sockaddr_any* aAddr,
|
||||
socklen_t aAddrLen) = 0;
|
||||
const struct sockaddr* aAddress,
|
||||
socklen_t aAddressLength) = 0;
|
||||
};
|
||||
|
||||
class ConnectionOrientedSocket : public DataSocket
|
||||
|
@ -215,7 +215,7 @@ ListenSocketIO::OnSocketCanAcceptWithoutBlocking()
|
||||
}
|
||||
|
||||
mCOSocketIO->Accept(fd,
|
||||
reinterpret_cast<union sockaddr_any*>(&storage),
|
||||
reinterpret_cast<struct sockaddr*>(&storage),
|
||||
addressLength);
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,8 @@ public:
|
||||
//
|
||||
|
||||
nsresult Accept(int aFd,
|
||||
const union sockaddr_any* aAddr,
|
||||
socklen_t aAddrLen) override;
|
||||
const struct sockaddr* aAddress,
|
||||
socklen_t aAddressLength) override;
|
||||
|
||||
// Methods for |DataSocket|
|
||||
//
|
||||
@ -321,7 +321,8 @@ StreamSocketIO::FireSocketError()
|
||||
|
||||
nsresult
|
||||
StreamSocketIO::Accept(int aFd,
|
||||
const union sockaddr_any* aAddr, socklen_t aAddrLen)
|
||||
const struct sockaddr* aAddress,
|
||||
socklen_t aAddressLength)
|
||||
{
|
||||
MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
|
||||
MOZ_ASSERT(GetConnectionStatus() == SOCKET_IS_CONNECTING);
|
||||
@ -329,8 +330,8 @@ StreamSocketIO::Accept(int aFd,
|
||||
SetSocket(aFd, SOCKET_IS_CONNECTED);
|
||||
|
||||
// Address setup
|
||||
mAddressLength = aAddrLen;
|
||||
memcpy(&mAddress, aAddr, mAddressLength);
|
||||
mAddressLength = aAddressLength;
|
||||
memcpy(&mAddress, aAddress, mAddressLength);
|
||||
|
||||
// Signal success
|
||||
NS_DispatchToMainThread(
|
||||
|
Loading…
Reference in New Issue
Block a user