2013-05-10 05:00:28 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
#include "nsINetAddr.idl"
|
|
|
|
|
|
|
|
interface nsIUDPSocketInternal;
|
2014-05-06 03:32:25 -07:00
|
|
|
interface nsIInputStream;
|
2013-05-10 05:00:28 -07:00
|
|
|
|
|
|
|
%{ C++
|
2013-11-12 04:54:17 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
union NetAddr;
|
|
|
|
}
|
|
|
|
}
|
2013-05-10 05:00:28 -07:00
|
|
|
%}
|
|
|
|
native NetAddr(mozilla::net::NetAddr);
|
|
|
|
[ptr] native NetAddrPtr(mozilla::net::NetAddr);
|
|
|
|
|
2014-08-26 18:05:26 -07:00
|
|
|
[scriptable, uuid(36ec5264-6a58-4cf2-ad9a-185292e0d1d1)]
|
2013-05-10 05:00:28 -07:00
|
|
|
interface nsIUDPSocketChild : nsISupports
|
|
|
|
{
|
|
|
|
readonly attribute unsigned short localPort;
|
|
|
|
readonly attribute AUTF8String localAddress;
|
2013-11-29 08:13:44 -08:00
|
|
|
attribute AUTF8String filterName;
|
|
|
|
|
2013-05-10 05:00:28 -07:00
|
|
|
// Tell the chrome process to bind the UDP socket to a given local host and port
|
2014-05-06 03:32:25 -07:00
|
|
|
void bind(in nsIUDPSocketInternal socket, in AUTF8String host, in unsigned short port,
|
|
|
|
in bool addressReuse, in bool loopback);
|
2013-05-10 05:00:28 -07:00
|
|
|
|
|
|
|
// Tell the chrome process to perform equivalent operations to all following methods
|
|
|
|
void send(in AUTF8String host, in unsigned short port,
|
|
|
|
[const, array, size_is(byteLength)] in uint8_t bytes,
|
|
|
|
in unsigned long byteLength);
|
|
|
|
// Send without DNS query
|
|
|
|
void sendWithAddr(in nsINetAddr addr,
|
|
|
|
[const, array, size_is(byteLength)] in uint8_t bytes,
|
|
|
|
in unsigned long byteLength);
|
|
|
|
[noscript] void sendWithAddress([const] in NetAddrPtr addr,
|
|
|
|
[const, array, size_is(byteLength)] in uint8_t bytes,
|
|
|
|
in unsigned long byteLength);
|
2014-05-06 03:32:25 -07:00
|
|
|
// Send input stream. This must be a buffered stream implementation.
|
|
|
|
void sendBinaryStream(in AUTF8String host, in unsigned short port, in nsIInputStream stream);
|
|
|
|
|
2013-05-10 05:00:28 -07:00
|
|
|
void close();
|
2014-05-06 03:32:25 -07:00
|
|
|
void joinMulticast(in AUTF8String multicastAddress, in AUTF8String iface);
|
|
|
|
void leaveMulticast(in AUTF8String multicastAddress, in AUTF8String iface);
|
2013-05-10 05:00:28 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal interface for callback from chrome process
|
|
|
|
*/
|
2014-05-06 03:32:25 -07:00
|
|
|
[scriptable, uuid(44cd9ad5-d574-4169-baf9-e1af0648a143)]
|
2013-05-10 05:00:28 -07:00
|
|
|
interface nsIUDPSocketInternal : nsISupports
|
|
|
|
{
|
2014-05-06 03:32:25 -07:00
|
|
|
// callback while socket is opened. localPort and localAddress is ready until this time.
|
|
|
|
void callListenerOpened();
|
|
|
|
// callback while socket is closed.
|
|
|
|
void callListenerClosed();
|
|
|
|
// callback while incoming packet is received.
|
|
|
|
void callListenerReceivedData(in AUTF8String host, in unsigned short port,
|
|
|
|
[const, array, size_is(dataLength)] in uint8_t data,
|
2013-05-10 05:00:28 -07:00
|
|
|
in unsigned long dataLength);
|
2014-05-06 03:32:25 -07:00
|
|
|
// callback while any error happened.
|
|
|
|
void callListenerError(in AUTF8String message, in AUTF8String filename, in uint32_t lineNumber);
|
2013-05-10 05:00:28 -07:00
|
|
|
};
|