mozilla::ipc::IPCResult UDPSocketParent::RecvOutgoingData(const UDPData& aData, const UDPSocketAddr& aAddr) { if (!mSocket) { NS_WARNING("sending socket is closed"); FireInternalError(__LINE__); return IPC_OK(); } nsresult rv; if (mFilter) { if (aAddr.type() != UDPSocketAddr::TNetAddr) { return IPC_OK(); } // TODO, Packet filter doesn't support input stream yet. if (aData.type() != UDPData::TArrayOfuint8_t) { return IPC_OK(); } bool allowed; const InfallibleTArray<uint8_t>& data(aData.get_ArrayOfuint8_t()); rv = mFilter->FilterPacket(&aAddr.get_NetAddr(), data.Elements(), data.Length(), nsISocketFilter::SF_OUTGOING, &allowed); // Sending unallowed data, kill content. if (NS_WARN_IF(NS_FAILED(rv)) || !allowed) { return IPC_FAIL(this, "Content tried to send non STUN packet"); } } switch(aData.type()) { case UDPData::TArrayOfuint8_t: Send(aData.get_ArrayOfuint8_t(), aAddr); break; case UDPData::TIPCStream: Send(aData.get_IPCStream(), aAddr); break; default: MOZ_ASSERT(false, "Invalid data type!"); return IPC_OK(); } return IPC_OK(); }
bool UDPSocketParent::RecvOutgoingData(const UDPData& aData, const UDPSocketAddr& aAddr) { MOZ_ASSERT(mSocket); nsresult rv; if (mFilter) { // TODO, Bug 933102, filter packets that are sent with hostname. // Until then we simply throw away packets that are sent to a hostname. if (aAddr.type() != UDPSocketAddr::TNetAddr) { return true; } // TODO, Packet filter doesn't support input stream yet. if (aData.type() != UDPData::TArrayOfuint8_t) { return true; } bool allowed; const InfallibleTArray<uint8_t>& data(aData.get_ArrayOfuint8_t()); rv = mFilter->FilterPacket(&aAddr.get_NetAddr(), data.Elements(), data.Length(), nsIUDPSocketFilter::SF_OUTGOING, &allowed); // Sending unallowed data, kill content. if (NS_WARN_IF(NS_FAILED(rv)) || !allowed) { return false; } } switch(aData.type()) { case UDPData::TArrayOfuint8_t: Send(aData.get_ArrayOfuint8_t(), aAddr); break; case UDPData::TInputStreamParams: Send(aData.get_InputStreamParams(), aAddr); break; default: MOZ_ASSERT(false, "Invalid data type!"); return true; } return true; }