Media/WebRTC/WebRTCE10S/NetworkProxyInterface: Difference between revisions

From MozillaWiki
< Media‎ | WebRTC‎ | WebRTCE10S
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:


==== Address Enumeration ====
==== Address Enumeration ====
This should be an RPC-style call.


  EnumerateInterfaces()
    nsresult EnumerateInterfaces(std::vector<Interface>* interfaces);
      
      
    Returns a sequence of:
Returns a sequence of:
    {
 
    struct Interface {
       string name;
       string name;
       PRNetAddr address;
       PRNetAddr address;
Line 12: Line 14:
     }
     }
     enum InterfaceType { Local, Wired, WiFi, Mobile, Virtual };
     enum InterfaceType { Local, Wired, WiFi, Mobile, Virtual };
it would be best if this were a synchronous RPC call, but if it has to be async we can live with that.


==== Socket Management ====
==== Socket Management ====


The following interfaces should be synchronous/RPC-style.
The following interfaces should be synchronous/RPC-style.
To create a socket:
To create a socket:
   
   
  nsresult CreateSocket(PRNetAddr* requested_address);
nsresult SocketCreate(PRNetAddr* requested_address, SocketHandle* handle);


You pass in a PRNetAddr with an IP address but an empty (0) port.
You pass in a PRNetAddr with an IP address but an empty (0) port.
On success, the port is filled in.
On success, the port is filled in, and the handle is valid.
 
 
To destroy a socket:


  nsresult SocketDestroy(SocketHandle handle);




This effectively closes it.


==== Packet Transmisson and Reception ====
==== Packet Transmisson and Reception ====
From content to chrome, we do:
  SendTo(SocketHandle handle,
              const void *buf,
              PRInt32 amount,
              PRIntn flags,
              PRNetAddr remoteAddress);
This call causes a packet to be sent to remoteAddress if (if possible);.
These values correspond to those in PR_SendTo (https://developer.mozilla.org/en-US/docs/PR_SendTo).
Note that this is asynchronous so there is no error return.
From chrome to content:
  PacketReceived(SocketHandle handle,
                          const void *buf,
                          PRInt32 amount,
                          PRNetAddr remoteAddress);
This message indicates that a packet has been received from some remote
side. Handle is the socket that the packet came in on. buf and amount contain
the packet. remoteAddress is the source address.
Finally:
  Error(SocketHandle)
This message indicates that something went wrong on the socket in
question and it is likely that you will no longer be able to send/receive.

Latest revision as of 10:11, 24 April 2013

Network Proxy Interfaces for WebRTC E10S Split

Address Enumeration

This should be an RPC-style call.

   nsresult EnumerateInterfaces(std::vector<Interface>* interfaces);
   

Returns a sequence of:

    struct Interface {
      string name;
      PRNetAddr address;
      InterfaceType type;
    }
    enum InterfaceType { Local, Wired, WiFi, Mobile, Virtual };

Socket Management

The following interfaces should be synchronous/RPC-style.

To create a socket:

nsresult SocketCreate(PRNetAddr* requested_address, SocketHandle* handle);

You pass in a PRNetAddr with an IP address but an empty (0) port. On success, the port is filled in, and the handle is valid.


To destroy a socket:

 nsresult SocketDestroy(SocketHandle handle);


This effectively closes it.

Packet Transmisson and Reception

From content to chrome, we do:

 SendTo(SocketHandle handle,
             const void *buf, 
             PRInt32 amount,
             PRIntn flags,
             PRNetAddr remoteAddress);

This call causes a packet to be sent to remoteAddress if (if possible);. These values correspond to those in PR_SendTo (https://developer.mozilla.org/en-US/docs/PR_SendTo). Note that this is asynchronous so there is no error return.


From chrome to content:

 PacketReceived(SocketHandle handle,
                         const void *buf, 
                         PRInt32 amount,
                         PRNetAddr remoteAddress);

This message indicates that a packet has been received from some remote side. Handle is the socket that the packet came in on. buf and amount contain the packet. remoteAddress is the source address.

Finally:

 Error(SocketHandle)

This message indicates that something went wrong on the socket in question and it is likely that you will no longer be able to send/receive.