mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:11:03 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- reapply Bug 1574573 - Disambiguate a use of Handle in XPCShellEnvironment.cpp r=Ehsan (a674c4b006) - Bug 1255707 - Part 2. Remove ScreenSizeChanged. r=snorp (3a93e4e768) - Bug 1250418 - Remove the assertion check of mCanSend in CompositorCh ld::ActorDestroy, r=nical (14bb402a1d) - Bug 1250718 - Improve layer logging for preserve-3d layers. r=thinker (f373a50040) - Bug 1232042 - Addendum: Add comment for mLayerManager check. r=jrmuizel (2b69aa784a) - Bug 1239861. Skip composite if vsync time is before force composite time. r=kats (5ee4038157) - Bug 1241678 - Fix low-volume null-deref crash. r=BenWa (b28d944615) - Rename PCompositor to PCompositorBridge. (bug 1258479 part 2, r=mattwoodrow) (dd535a9bdd) - Bug 1220184 - Eliminate Gingerbread compatibility. r=froydnj, r=nalexander (dce9e4f9e8) - Bug 1250917 - Remove NS_SUCCESS_I_DID_SOMETHING; r=bholley (9dd6fe351b) - Bug 1155241: Check mInstanceOwner for nullptr in nsObjectLoadingContent::PluginDestroyed; r=smaug (ad60991e3e) - Bug 1229220 - Update the scrollbar visibility prefs when initializing a TabChild; r=smaug (28997e0a6d) - Bug 1252262 - Don't combine the client offset into the outer rect for the child process. r=jimm (f415c0418e) - Bug 1249943 - Make test_basic_pan work on Fennec and Linux as well. r=botond (657c940be1) - bit of bug 1245765 part 5 (82463f7eaa) - Bug 1207512 - Remove the JS_IsRunning call in nsObjectLoadingContent::ScriptRequestPluginInstance; r=bholley (76047284a6) - Bug 1239463 - Do not assert when notifying an inactive document about changed content from the plugin crash notification. r=bz (03bf38a683) - Bug 1192450 - Remove PlayPreview registration from Shumway. r=jet (9b6e131876) - Bug 1200602 - Use the alternate content for <applet>. r=kmachulis (843fccf0aa)
This commit is contained in:
@@ -51,6 +51,13 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We want to claim that the type for SWF movies is unsupported,
|
||||
// so that the internal SWF player's stream converter will get used.
|
||||
if (aType.LowerCaseEqualsLiteral("application/x-shockwave-flash") &&
|
||||
nsContentUtils::IsSWFPlayerEnabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsCString& flatType = PromiseFlatCString(aType);
|
||||
nsresult rv = IsTypeSupportedInternal(flatType, aIsTypeSupported);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
+1
-17
@@ -287,23 +287,7 @@ ScrollbarsProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
||||
and because embedding apps have no interface for implementing this
|
||||
themselves, and therefore the implementation must be internal. */
|
||||
|
||||
nsCOMPtr<nsIScrollable> scroller =
|
||||
do_QueryInterface(mDOMWindow->GetDocShell());
|
||||
|
||||
if (scroller) {
|
||||
int32_t prefValue;
|
||||
|
||||
if (aVisible) {
|
||||
prefValue = nsIScrollable::Scrollbar_Auto;
|
||||
} else {
|
||||
prefValue = nsIScrollable::Scrollbar_Never;
|
||||
}
|
||||
|
||||
scroller->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_Y, prefValue);
|
||||
scroller->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, prefValue);
|
||||
}
|
||||
nsContentUtils::SetScrollbarsVisibility(mDOMWindow->GetDocShell(), aVisible);
|
||||
|
||||
/* Notably absent is the part where we notify the chrome window using
|
||||
GetBrowserChrome()->SetChromeFlags(). Given the possibility of multiple
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIURI.h"
|
||||
@@ -6582,6 +6583,20 @@ nsContentUtils::IsPDFJSEnabled()
|
||||
return NS_SUCCEEDED(rv) && canConvert;
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::IsSWFPlayerEnabled()
|
||||
{
|
||||
nsCOMPtr<nsIStreamConverterService> convServ =
|
||||
do_GetService("@mozilla.org/streamConverters;1");
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
bool canConvert = false;
|
||||
if (convServ) {
|
||||
rv = convServ->CanConvert("application/x-shockwave-flash",
|
||||
"text/html", &canConvert);
|
||||
}
|
||||
return NS_SUCCEEDED(rv) && canConvert;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDocumentLoaderFactory>
|
||||
nsContentUtils::FindInternalContentViewer(const nsACString& aType,
|
||||
ContentViewerType* aLoaderType)
|
||||
@@ -8924,3 +8939,24 @@ nsContentUtils::IsSpecificAboutPage(JSObject* aGlobal, const char* aUri)
|
||||
uri->GetSpec(spec);
|
||||
return spec.EqualsASCII(aUri);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsContentUtils::SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible)
|
||||
{
|
||||
nsCOMPtr<nsIScrollable> scroller = do_QueryInterface(aDocShell);
|
||||
|
||||
if (scroller) {
|
||||
int32_t prefValue;
|
||||
|
||||
if (aVisible) {
|
||||
prefValue = nsIScrollable::Scrollbar_Auto;
|
||||
} else {
|
||||
prefValue = nsIScrollable::Scrollbar_Never;
|
||||
}
|
||||
|
||||
scroller->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_Y, prefValue);
|
||||
scroller->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, prefValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2137,6 +2137,11 @@ public:
|
||||
*/
|
||||
static bool IsPDFJSEnabled();
|
||||
|
||||
/**
|
||||
* Checks if internal SWF player is enabled.
|
||||
*/
|
||||
static bool IsSWFPlayerEnabled();
|
||||
|
||||
enum ContentViewerType
|
||||
{
|
||||
TYPE_UNSUPPORTED,
|
||||
@@ -2570,6 +2575,8 @@ public:
|
||||
*/
|
||||
static bool IsSpecificAboutPage(JSObject* aGlobal, const char* aUri);
|
||||
|
||||
static void SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible);
|
||||
|
||||
private:
|
||||
static bool InitializeEventTable();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "nsDOMWindowUtils.h"
|
||||
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "mozilla/layers/LayerTransactionChild.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/dom/HTMLIFrameElement.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
|
||||
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
||||
|
||||
@@ -1687,7 +1687,7 @@ nsFrameLoader::ShouldUseRemoteProcess()
|
||||
// Don't try to launch nested children if we don't have OMTC.
|
||||
// They won't render!
|
||||
if (XRE_IsContentProcess() &&
|
||||
!CompositorChild::ChildProcessHasCompositor()) {
|
||||
!CompositorBridgeChild::ChildProcessHasCompositor()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -557,6 +557,11 @@ IsPluginEnabledByExtension(nsIURI* uri, nsCString& mimeType)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Disables any native SWF plugins, when internal SWF player is enabled.
|
||||
if (ext.EqualsIgnoreCase("swf") && nsContentUtils::IsSWFPlayerEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
||||
|
||||
if (!pluginHost) {
|
||||
@@ -2648,8 +2653,8 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
|
||||
EventStates newState = ObjectState();
|
||||
|
||||
if (newState != aOldState) {
|
||||
NS_ASSERTION(thisContent->IsInComposedDoc(), "Something is confused");
|
||||
// This will trigger frame construction
|
||||
NS_ASSERTION(InActiveDocument(thisContent), "Something is confused");
|
||||
EventStates changedBits = aOldState ^ newState;
|
||||
|
||||
{
|
||||
@@ -2657,6 +2662,7 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
|
||||
doc->ContentStateChanged(thisContent, changedBits);
|
||||
}
|
||||
if (aSync) {
|
||||
NS_ASSERTION(InActiveDocument(thisContent), "Something is confused");
|
||||
// Make sure that frames are actually constructed immediately.
|
||||
doc->FlushPendingNotifications(Flush_Frames);
|
||||
}
|
||||
@@ -2690,6 +2696,13 @@ nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType)
|
||||
return eType_Document;
|
||||
}
|
||||
|
||||
// Faking support of the SWF content as a document for EMBED tags
|
||||
// when internal SWF player is enabled.
|
||||
if (aMIMEType.LowerCaseEqualsLiteral("application/x-shockwave-flash") &&
|
||||
nsContentUtils::IsSWFPlayerEnabled()) {
|
||||
return eType_Document;
|
||||
}
|
||||
|
||||
if ((caps & eSupportDocuments) && IsSupportedDocument(aMIMEType)) {
|
||||
return eType_Document;
|
||||
}
|
||||
@@ -2752,8 +2765,10 @@ nsObjectLoadingContent::PluginDestroyed()
|
||||
// plugins in plugin host. Invalidate instance owner / prototype but otherwise
|
||||
// don't take any action.
|
||||
TeardownProtoChain();
|
||||
mInstanceOwner->Destroy();
|
||||
mInstanceOwner = nullptr;
|
||||
if (mInstanceOwner) {
|
||||
mInstanceOwner->Destroy();
|
||||
mInstanceOwner = nullptr;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -2814,8 +2829,7 @@ nsObjectLoadingContent::ScriptRequestPluginInstance(JSContext* aCx,
|
||||
aCx == nsContentUtils::GetCurrentJSContext());
|
||||
bool callerIsContentJS = (nsContentUtils::GetCurrentJSContext() &&
|
||||
!nsContentUtils::IsCallerChrome() &&
|
||||
!nsContentUtils::IsCallerContentXBL() &&
|
||||
JS_IsRunning(aCx));
|
||||
!nsContentUtils::IsCallerContentXBL());
|
||||
|
||||
nsCOMPtr<nsIContent> thisContent =
|
||||
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||
@@ -2947,7 +2961,8 @@ nsObjectLoadingContent::LoadFallback(FallbackType aType, bool aNotify) {
|
||||
aType = eFallbackAlternate;
|
||||
}
|
||||
|
||||
if (thisContent->IsHTMLElement(nsGkAtoms::object) &&
|
||||
if ((thisContent->IsHTMLElement(nsGkAtoms::object) ||
|
||||
thisContent->IsHTMLElement(nsGkAtoms::applet)) &&
|
||||
(aType == eFallbackUnsupported ||
|
||||
aType == eFallbackDisabled ||
|
||||
aType == eFallbackBlocklisted))
|
||||
|
||||
@@ -265,6 +265,7 @@ support-files =
|
||||
[test_anonymousContent_insert.html]
|
||||
[test_anonymousContent_manipulate_content.html]
|
||||
[test_anonymousContent_style_csp.html]
|
||||
[test_applet_alternate_content.html]
|
||||
[test_appname_override.html]
|
||||
[test_async_setTimeout_stack.html]
|
||||
[test_async_setTimeout_stack_across_globals.html]
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1200602
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1200602</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SpecialPowers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1200602">Mozilla Bug 1200602</a>
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
function test() {
|
||||
"use strict";
|
||||
|
||||
const objLC = SpecialPowers.Ci.nsIObjectLoadingContent;
|
||||
let obj = document.createElement("applet");
|
||||
obj.appendChild(document.createTextNode("alternate content"));
|
||||
document.body.appendChild(obj);
|
||||
|
||||
obj instanceof objLC;
|
||||
obj = SpecialPowers.wrap(obj);
|
||||
|
||||
// We expect this tag to simply go to alternate content, not get a
|
||||
// pluginProblem binding or fire any events.
|
||||
ok(obj.displayedType == objLC.TYPE_NULL, "expected null type");
|
||||
ok(obj.pluginFallbackType == objLC.PLUGIN_ALTERNATE,
|
||||
"expected alternate fallback mode");
|
||||
}
|
||||
|
||||
// Test all non-plugin types these tags can load to make sure none of them
|
||||
// trigger plugin-specific fallbacks when loaded with no URI
|
||||
test();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -75,7 +75,7 @@ function nextTest() {
|
||||
|
||||
function runNextTest() {
|
||||
if (gTestIndex < gTestWindows.length) {
|
||||
testWindow = window.open(gTestWindows[gTestIndex], "", "width=500,height=500");
|
||||
testWindow = window.open(gTestWindows[gTestIndex], "", "width=500,height=500,scrollbars=yes");
|
||||
// We'll wait for the window to load, then make sure our window is refocused
|
||||
// before starting the test, which will get kicked off on "focus".
|
||||
// This ensures that we're essentially back on the primary "desktop" on
|
||||
|
||||
@@ -45,9 +45,8 @@
|
||||
#include "mozilla/ipc/TestShellChild.h"
|
||||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
#include "mozilla/layers/APZChild.h"
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
#include "mozilla/layers/PCompositorBridgeChild.h"
|
||||
#include "mozilla/layers/SharedBufferManagerChild.h"
|
||||
#include "mozilla/layout/RenderFrameChild.h"
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
@@ -596,9 +595,6 @@ ReinitTaskTracer(void* /*aUnused*/)
|
||||
|
||||
ContentChild::ContentChild()
|
||||
: mID(uint64_t(-1))
|
||||
#ifdef ANDROID
|
||||
, mScreenSize(0, 0)
|
||||
#endif
|
||||
, mCanOverrideProcessName(true)
|
||||
, mIsAlive(true)
|
||||
{
|
||||
@@ -1278,7 +1274,7 @@ PCompositorBridgeChild*
|
||||
ContentChild::AllocPCompositorBridgeChild(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
{
|
||||
return CompositorChild::Create(aTransport, aOtherProcess);
|
||||
return CompositorBridgeChild::Create(aTransport, aOtherProcess);
|
||||
}
|
||||
|
||||
PSharedBufferManagerChild*
|
||||
@@ -2499,17 +2495,6 @@ ContentChild::RecvAddPermission(const IPC::Permission& permission)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvScreenSizeChanged(const gfx::IntSize& size)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
mScreenSize = size;
|
||||
#else
|
||||
NS_RUNTIMEABORT("Message currently only expected on android");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvFlushMemory(const nsString& reason)
|
||||
{
|
||||
|
||||
@@ -431,8 +431,6 @@ public:
|
||||
|
||||
virtual bool RecvAddPermission(const IPC::Permission& permission) override;
|
||||
|
||||
virtual bool RecvScreenSizeChanged(const gfx::IntSize &size) override;
|
||||
|
||||
virtual bool RecvFlushMemory(const nsString& reason) override;
|
||||
|
||||
virtual bool RecvActivateA11y() override;
|
||||
@@ -534,10 +532,6 @@ public:
|
||||
RecvPushSubscriptionChange(const nsCString& aScope,
|
||||
const IPC::Principal& aPrincipal) override;
|
||||
|
||||
#ifdef ANDROID
|
||||
gfx::IntSize GetScreenSize() { return mScreenSize; }
|
||||
#endif
|
||||
|
||||
// Get the directory for IndexedDB files. We query the parent for this and
|
||||
// cache the value
|
||||
nsString &GetIndexedDBPath();
|
||||
@@ -636,10 +630,6 @@ private:
|
||||
|
||||
AppInfo mAppInfo;
|
||||
|
||||
#ifdef ANDROID
|
||||
gfx::IntSize mScreenSize;
|
||||
#endif
|
||||
|
||||
bool mIsForApp;
|
||||
bool mIsForBrowser;
|
||||
bool mCanOverrideProcessName;
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
#include "mozilla/layers/PAPZParent.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/ImageBridgeParent.h"
|
||||
#include "mozilla/layers/SharedBufferManagerParent.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
@@ -1912,7 +1912,7 @@ ContentParent::AllocateLayerTreeId(ContentParent* aContent,
|
||||
TabParent* aTopLevel, const TabId& aTabId,
|
||||
uint64_t* aId)
|
||||
{
|
||||
*aId = CompositorParent::AllocateLayerTreeId();
|
||||
*aId = CompositorBridgeParent::AllocateLayerTreeId();
|
||||
|
||||
if (!gfxPlatform::AsyncPanZoomEnabled()) {
|
||||
return true;
|
||||
@@ -1922,7 +1922,7 @@ ContentParent::AllocateLayerTreeId(ContentParent* aContent,
|
||||
return false;
|
||||
}
|
||||
|
||||
return CompositorParent::UpdateRemoteContentController(*aId, aContent,
|
||||
return CompositorBridgeParent::UpdateRemoteContentController(*aId, aContent,
|
||||
aTabId, aTopLevel);
|
||||
}
|
||||
|
||||
@@ -1970,7 +1970,7 @@ ContentParent::RecvDeallocateLayerTreeId(const uint64_t& aId)
|
||||
auto iter = NestedBrowserLayerIds().find(this);
|
||||
if (iter != NestedBrowserLayerIds().end() &&
|
||||
iter->second.find(aId) != iter->second.end()) {
|
||||
CompositorParent::DeallocateLayerTreeId(aId);
|
||||
CompositorBridgeParent::DeallocateLayerTreeId(aId);
|
||||
} else {
|
||||
// You can't deallocate layer tree ids that you didn't allocate
|
||||
KillHard("DeallocateLayerTreeId");
|
||||
@@ -2534,14 +2534,14 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
||||
|
||||
if (aSetupOffMainThreadCompositing) {
|
||||
// NB: internally, this will send an IPC message to the child
|
||||
// process to get it to create the CompositorChild. This
|
||||
// process to get it to create the CompositorBridgeChild. This
|
||||
// message goes through the regular IPC queue for this
|
||||
// channel, so delivery will happen-before any other messages
|
||||
// we send. The CompositorChild must be created before any
|
||||
// we send. The CompositorBridgeChild must be created before any
|
||||
// PBrowsers are created, because they rely on the Compositor
|
||||
// already being around. (Creation is async, so can't happen
|
||||
// on demand.)
|
||||
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
|
||||
bool useOffMainThreadCompositing = !!CompositorBridgeParent::CompositorLoop();
|
||||
if (useOffMainThreadCompositing) {
|
||||
DebugOnly<bool> opened = PCompositorBridge::Open(this);
|
||||
MOZ_ASSERT(opened);
|
||||
@@ -3349,7 +3349,7 @@ PCompositorBridgeParent*
|
||||
ContentParent::AllocPCompositorBridgeParent(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
{
|
||||
return CompositorParent::Create(aTransport, aOtherProcess);
|
||||
return CompositorBridgeParent::Create(aTransport, aOtherProcess);
|
||||
}
|
||||
|
||||
gfx::PVRManagerParent*
|
||||
|
||||
@@ -530,6 +530,7 @@ child:
|
||||
|
||||
async UpdateDimensions(CSSRect rect, CSSSize size,
|
||||
ScreenOrientationInternal orientation,
|
||||
LayoutDeviceIntPoint clientOffset,
|
||||
LayoutDeviceIntPoint chromeDisp) compressall;
|
||||
|
||||
async SizeModeChanged(nsSizeMode sizeMode);
|
||||
|
||||
@@ -603,8 +603,6 @@ child:
|
||||
// nsIPermissionManager messages
|
||||
async AddPermission(Permission permission);
|
||||
|
||||
async ScreenSizeChanged(IntSize size);
|
||||
|
||||
async Volumes(VolumeInfo[] volumes);
|
||||
|
||||
async FlushMemory(nsString reason);
|
||||
|
||||
+22
-19
@@ -33,7 +33,7 @@
|
||||
#include "mozilla/layers/APZCCallbackHelper.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZEventState.h"
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "mozilla/layers/DoubleTapToZoom.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
#include "mozilla/layers/InputAPZContext.h"
|
||||
@@ -840,6 +840,9 @@ TabChild::Init()
|
||||
do_QueryInterface(window->GetChromeEventHandler());
|
||||
docShell->SetChromeEventHandler(chromeHandler);
|
||||
|
||||
nsContentUtils::SetScrollbarsVisibility(window->GetDocShell(),
|
||||
!!(mChromeFlags & nsIWebBrowserChrome::CHROME_SCROLLBARS));
|
||||
|
||||
nsWeakPtr weakPtrThis = do_GetWeakReference(static_cast<nsITabChild*>(this)); // for capture by the lambda
|
||||
ContentReceivedInputBlockCallback callback(
|
||||
[weakPtrThis](const ScrollableLayerGuid& aGuid,
|
||||
@@ -1210,7 +1213,7 @@ TabChild::ActorDestroy(ActorDestroyReason why)
|
||||
mTabChildGlobal->mMessageManager = nullptr;
|
||||
}
|
||||
|
||||
CompositorChild* compositorChild = static_cast<CompositorChild*>(CompositorChild::Get());
|
||||
CompositorBridgeChild* compositorChild = static_cast<CompositorBridgeChild*>(CompositorBridgeChild::Get());
|
||||
compositorChild->CancelNotifyAfterRemotePaint(this);
|
||||
|
||||
if (GetTabId() != 0) {
|
||||
@@ -1634,6 +1637,7 @@ TabChild::RecvShow(const ScreenIntSize& aSize,
|
||||
bool
|
||||
TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size,
|
||||
const ScreenOrientationInternal& orientation,
|
||||
const LayoutDeviceIntPoint& clientOffset,
|
||||
const LayoutDeviceIntPoint& chromeDisp)
|
||||
{
|
||||
if (!mRemoteFrame) {
|
||||
@@ -1641,6 +1645,7 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size,
|
||||
}
|
||||
|
||||
mUnscaledOuterRect = rect;
|
||||
mClientOffset = clientOffset;
|
||||
mChromeDisp = chromeDisp;
|
||||
|
||||
mOrientation = orientation;
|
||||
@@ -1659,8 +1664,8 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size,
|
||||
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
||||
true);
|
||||
|
||||
mPuppetWidget->Resize(screenRect.x + chromeDisp.x,
|
||||
screenRect.y + chromeDisp.y,
|
||||
mPuppetWidget->Resize(screenRect.x + clientOffset.x + chromeDisp.x,
|
||||
screenRect.y + clientOffset.y + chromeDisp.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
|
||||
return true;
|
||||
@@ -1752,9 +1757,8 @@ TabChild::NotifyAPZStateChange(const ViewID& aViewId,
|
||||
if (aChange == layers::GeckoContentController::APZStateChange::TransformEnd) {
|
||||
// This is used by tests to determine when the APZ is done doing whatever
|
||||
// it's doing. XXX generify this as needed when writing additional tests.
|
||||
DispatchMessageManagerMessage(
|
||||
NS_LITERAL_STRING("APZ:TransformEnd"),
|
||||
NS_LITERAL_STRING("{}"));
|
||||
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
||||
observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2534,9 +2538,9 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
|
||||
|
||||
// Pushing layers transactions directly to a separate
|
||||
// compositor context.
|
||||
PCompositorBridgeChild* compositorChild = CompositorChild::Get();
|
||||
PCompositorBridgeChild* compositorChild = CompositorBridgeChild::Get();
|
||||
if (!compositorChild) {
|
||||
NS_WARNING("failed to get CompositorChild instance");
|
||||
NS_WARNING("failed to get CompositorBridgeChild instance");
|
||||
PRenderFrameChild::Send__delete__(remoteFrame);
|
||||
return false;
|
||||
}
|
||||
@@ -2642,7 +2646,7 @@ TabChild::NotifyPainted()
|
||||
void
|
||||
TabChild::MakeVisible()
|
||||
{
|
||||
CompositorChild* compositor = CompositorChild::Get();
|
||||
CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
|
||||
if (UsingCompositorLRU()) {
|
||||
compositor->SendNotifyVisible(mLayersId);
|
||||
}
|
||||
@@ -2655,12 +2659,12 @@ TabChild::MakeVisible()
|
||||
void
|
||||
TabChild::MakeHidden()
|
||||
{
|
||||
CompositorChild* compositor = CompositorChild::Get();
|
||||
CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
|
||||
if (UsingCompositorLRU()) {
|
||||
compositor->SendNotifyHidden(mLayersId);
|
||||
} else {
|
||||
// Clear cached resources directly. This avoids one extra IPC
|
||||
// round-trip from CompositorChild to CompositorParent when
|
||||
// round-trip from CompositorBridgeChild to CompositorBridgeParent when
|
||||
// CompositorLRU is not used.
|
||||
compositor->RecvClearCachedResources(mLayersId);
|
||||
}
|
||||
@@ -2814,8 +2818,7 @@ TabChild::DidComposite(uint64_t aTransactionId,
|
||||
MOZ_ASSERT(mPuppetWidget->GetLayerManager()->GetBackendType() ==
|
||||
LayersBackend::LAYERS_CLIENT);
|
||||
|
||||
ClientLayerManager *manager =
|
||||
static_cast<ClientLayerManager*>(mPuppetWidget->GetLayerManager());
|
||||
ClientLayerManager *manager = mPuppetWidget->GetLayerManager()->AsClientLayerManager();
|
||||
|
||||
manager->DidComposite(aTransactionId, aCompositeStart, aCompositeEnd);
|
||||
}
|
||||
@@ -2895,10 +2898,10 @@ TabChild::OnHideTooltip()
|
||||
bool
|
||||
TabChild::RecvRequestNotifyAfterRemotePaint()
|
||||
{
|
||||
// Get the CompositorChild instance for this content thread.
|
||||
CompositorChild* compositor = CompositorChild::Get();
|
||||
// Get the CompositorBridgeChild instance for this content thread.
|
||||
CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
|
||||
|
||||
// Tell the CompositorChild that, when it gets a RemotePaintIsReady
|
||||
// Tell the CompositorBridgeChild that, when it gets a RemotePaintIsReady
|
||||
// message that it should forward it us so that we can bounce it to our
|
||||
// RenderFrameParent.
|
||||
compositor->RequestNotifyAfterRemotePaint(this);
|
||||
@@ -2924,8 +2927,8 @@ TabChild::RecvUIResolutionChanged(const float& aDpi, const double& aScale)
|
||||
ScreenIntSize screenSize = GetInnerSize();
|
||||
if (mHasValidInnerSize && oldScreenSize != screenSize) {
|
||||
ScreenIntRect screenRect = GetOuterRect();
|
||||
mPuppetWidget->Resize(screenRect.x + mChromeDisp.x,
|
||||
screenRect.y + mChromeDisp.y,
|
||||
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeDisp.x,
|
||||
screenRect.y + mClientOffset.y + mChromeDisp.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
||||
|
||||
@@ -326,6 +326,7 @@ public:
|
||||
virtual bool RecvUpdateDimensions(const CSSRect& rect,
|
||||
const CSSSize& size,
|
||||
const ScreenOrientationInternal& orientation,
|
||||
const LayoutDeviceIntPoint& aClientOffset,
|
||||
const LayoutDeviceIntPoint& chromeDisp) override;
|
||||
|
||||
virtual bool
|
||||
@@ -551,6 +552,7 @@ public:
|
||||
|
||||
nsresult CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut);
|
||||
|
||||
LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; }
|
||||
LayoutDeviceIntPoint GetChromeDisplacement() { return mChromeDisp; };
|
||||
|
||||
bool IPCOpen() { return mIPCOpen; }
|
||||
@@ -698,6 +700,8 @@ private:
|
||||
SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback;
|
||||
bool mHasValidInnerSize;
|
||||
bool mDestroyed;
|
||||
// Position of client area relative to the outer window
|
||||
LayoutDeviceIntPoint mClientOffset;
|
||||
// Position of tab, relative to parent widget (typically the window)
|
||||
LayoutDeviceIntPoint mChromeDisp;
|
||||
TabId mUniqueId;
|
||||
|
||||
+22
-19
@@ -29,7 +29,7 @@
|
||||
#include "mozilla/ipc/DocumentRendererParent.h"
|
||||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
#include "mozilla/layers/AsyncDragMetrics.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/InputAPZContext.h"
|
||||
#include "mozilla/layout/RenderFrameParent.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
@@ -941,28 +941,28 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size)
|
||||
if (mIsDestroyed) {
|
||||
return;
|
||||
}
|
||||
hal::ScreenConfiguration config;
|
||||
hal::GetCurrentScreenConfiguration(&config);
|
||||
ScreenOrientationInternal orientation = config.orientation();
|
||||
LayoutDeviceIntPoint chromeOffset = -GetChildProcessOffset();
|
||||
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
if (!widget) {
|
||||
NS_WARNING("No widget found in TabParent::UpdateDimensions");
|
||||
return;
|
||||
}
|
||||
nsIntRect contentRect = rect;
|
||||
contentRect.x += widget->GetClientOffset().x;
|
||||
contentRect.y += widget->GetClientOffset().y;
|
||||
|
||||
hal::ScreenConfiguration config;
|
||||
hal::GetCurrentScreenConfiguration(&config);
|
||||
ScreenOrientationInternal orientation = config.orientation();
|
||||
LayoutDeviceIntPoint clientOffset = widget->GetClientOffset();
|
||||
LayoutDeviceIntPoint chromeOffset = -GetChildProcessOffset();
|
||||
|
||||
if (!mUpdatedDimensions || mOrientation != orientation ||
|
||||
mDimensions != size || !mRect.IsEqualEdges(contentRect) ||
|
||||
mDimensions != size || !mRect.IsEqualEdges(rect) ||
|
||||
clientOffset != mClientOffset ||
|
||||
chromeOffset != mChromeOffset) {
|
||||
|
||||
mUpdatedDimensions = true;
|
||||
mRect = contentRect;
|
||||
mRect = rect;
|
||||
mDimensions = size;
|
||||
mOrientation = orientation;
|
||||
mClientOffset = clientOffset;
|
||||
mChromeOffset = chromeOffset;
|
||||
|
||||
CSSToLayoutDeviceScale widgetScale = widget->GetDefaultScale();
|
||||
@@ -977,7 +977,7 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size)
|
||||
CSSRect unscaledRect = devicePixelRect / widgetScale;
|
||||
CSSSize unscaledSize = devicePixelSize / widgetScale;
|
||||
Unused << SendUpdateDimensions(unscaledRect, unscaledSize,
|
||||
orientation, chromeOffset);
|
||||
orientation, clientOffset, chromeOffset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2874,8 +2874,9 @@ TabParent::RequestNotifyLayerTreeReady()
|
||||
if (!frame) {
|
||||
mNeedLayerTreeReadyNotification = true;
|
||||
} else {
|
||||
CompositorParent::RequestNotifyLayerTreeReady(frame->GetLayersId(),
|
||||
new LayerTreeUpdateObserver());
|
||||
CompositorBridgeParent::RequestNotifyLayerTreeReady(
|
||||
frame->GetLayersId(),
|
||||
new LayerTreeUpdateObserver());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2888,8 +2889,9 @@ TabParent::RequestNotifyLayerTreeCleared()
|
||||
return false;
|
||||
}
|
||||
|
||||
CompositorParent::RequestNotifyLayerTreeCleared(frame->GetLayersId(),
|
||||
new LayerTreeUpdateObserver());
|
||||
CompositorBridgeParent::RequestNotifyLayerTreeCleared(
|
||||
frame->GetLayersId(),
|
||||
new LayerTreeUpdateObserver());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2924,12 +2926,13 @@ TabParent::SwapLayerTreeObservers(TabParent* aOther)
|
||||
|
||||
RenderFrameParent* rfp = GetRenderFrame();
|
||||
RenderFrameParent* otherRfp = aOther->GetRenderFrame();
|
||||
if(!rfp || !otherRfp) {
|
||||
if (!rfp || !otherRfp) {
|
||||
return;
|
||||
}
|
||||
|
||||
CompositorParent::SwapLayerTreeObservers(rfp->GetLayersId(),
|
||||
otherRfp->GetLayersId());
|
||||
CompositorBridgeParent::SwapLayerTreeObservers(
|
||||
rfp->GetLayersId(),
|
||||
otherRfp->GetLayersId());
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -602,6 +602,7 @@ protected:
|
||||
CSSToLayoutDeviceScale mDefaultScale;
|
||||
bool mUpdatedDimensions;
|
||||
nsSizeMode mSizeMode;
|
||||
LayoutDeviceIntPoint mClientOffset;
|
||||
LayoutDeviceIntPoint mChromeOffset;
|
||||
|
||||
private:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MediaSystemResourceManagerParent.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "MediaSystemResourceService.h"
|
||||
@@ -46,7 +46,7 @@ MediaSystemResourceService::Shutdown()
|
||||
MediaSystemResourceService::MediaSystemResourceService()
|
||||
: mDestroyed(false)
|
||||
{
|
||||
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// The maximum number of hardware resoureces available.
|
||||
// XXX need to hange to a dynamic way.
|
||||
@@ -82,7 +82,7 @@ MediaSystemResourceService::Acquire(media::MediaSystemResourceManagerParent* aPa
|
||||
MediaSystemResourceType aResourceType,
|
||||
bool aWillWait)
|
||||
{
|
||||
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
if (mDestroyed) {
|
||||
@@ -123,7 +123,7 @@ MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerPar
|
||||
uint32_t aId,
|
||||
MediaSystemResourceType aResourceType)
|
||||
{
|
||||
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
if (mDestroyed) {
|
||||
|
||||
@@ -168,7 +168,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s #Windows can't change size on Android # b2g(Windows can't change size on B2G) b2g-debug(Windows can't change size on B2G) b2g-desktop(Windows can't change size on B2G)
|
||||
[test_toJSON.html]
|
||||
[test_window_bar.html]
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
|
||||
[test_bug1022869.html]
|
||||
[test_bug1112040.html]
|
||||
[test_bug1171215.html]
|
||||
|
||||
@@ -48,7 +48,8 @@ function testWindow(w)
|
||||
}
|
||||
else {
|
||||
// w.location.search == '?true' if we expect the bars to be on, and
|
||||
// '?false' otherwise.
|
||||
// '?false' otherwise. By default, no bars are enabled, so '?default'
|
||||
// can be handled the same way as '?false'.
|
||||
var enabled = w.location.search == '?true';
|
||||
is(w[feature].visible, enabled, feature + ' should follow window.open settings.');
|
||||
}
|
||||
@@ -64,7 +65,7 @@ function testWindow(w)
|
||||
w.close();
|
||||
|
||||
numWindows++;
|
||||
if (numWindows == 2) {
|
||||
if (numWindows == 3) {
|
||||
// We're done!
|
||||
SimpleTest.finish();
|
||||
}
|
||||
@@ -87,6 +88,10 @@ var noBarsWindow =
|
||||
'personalbar=no,status=no,scrollbars=no',
|
||||
false);
|
||||
|
||||
var defaultWindow =
|
||||
window.open('file_window_bar.html?default', 'default-bars',
|
||||
'width=500,height=500', false);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
+20
-20
@@ -54,18 +54,18 @@ On Windows, it should be through **DwmGetCompositionTimingInfo**.
|
||||
#Compositor
|
||||
When the **CompositorVsyncDispatcher** is notified of the vsync event, the **CompositorVsyncObserver** associated with the **CompositorVsyncDispatcher** begins execution.
|
||||
Since the **CompositorVsyncDispatcher** executes on the *Hardware Vsync Thread* and the **Compositor** composites on the *CompositorThread*, the **CompositorVsyncObserver** posts a task to the *CompositorThread*.
|
||||
The **CompositorParent** then composites.
|
||||
The **CompositorBridgeParent** then composites.
|
||||
The model where the **CompositorVsyncDispatcher** notifies components on the *Hardware Vsync Thread*, and the component schedules the task on the appropriate thread is used everywhere.
|
||||
|
||||
The **CompositorVsyncObserver** listens to vsync events as needed and stops listening to vsync when composites are no longer scheduled or required.
|
||||
Every **CompositorParent** is associated and tied to one **CompositorVsyncObserver**, which is associated with the **CompositorVsyncDispatcher**.
|
||||
Each **CompositorParent** is associated with one widget and is created when a new platform window or **nsBaseWidget** is created.
|
||||
The **CompositorParent**, **CompositorVsyncDispatcher**, **CompositorVsyncObserver**, and **nsBaseWidget** all have the same lifetimes, which are created and destroyed together.
|
||||
Every **CompositorBridgeParent** is associated and tied to one **CompositorVsyncObserver**, which is associated with the **CompositorVsyncDispatcher**.
|
||||
Each **CompositorBridgeParent** is associated with one widget and is created when a new platform window or **nsBaseWidget** is created.
|
||||
The **CompositorBridgeParent**, **CompositorVsyncDispatcher**, **CompositorVsyncObserver**, and **nsBaseWidget** all have the same lifetimes, which are created and destroyed together.
|
||||
|
||||
###CompositorVsyncDispatcher
|
||||
The **CompositorVsyncDispatcher** executes on the *Hardware Vsync Thread*.
|
||||
It contains references to the **nsBaseWidget** it is associated with and has a lifetime equal to the **nsBaseWidget**.
|
||||
The **CompositorVsyncDispatcher** is responsible for notifying the **CompositorParent** that a vsync event has occured.
|
||||
The **CompositorVsyncDispatcher** is responsible for notifying the **CompositorBridgeParent** that a vsync event has occured.
|
||||
There can be multiple **CompositorVsyncDispatchers** per **Display**, one **CompositorVsyncDispatcher** per window.
|
||||
The only responsibility of the **CompositorVsyncDispatcher** is to notify components when a vsync event has occured, and to stop listening to vsync when no components require vsync events.
|
||||
We require one **CompositorVsyncDispatcher** per window so that we can handle multiple **Displays**.
|
||||
@@ -112,29 +112,29 @@ The **GeckoTouchDispatcher** handles this case by always forcing the **Composito
|
||||
|
||||
###Widget, Compositor, CompositorVsyncDispatcher, GeckoTouchDispatcher Shutdown Procedure
|
||||
When the [nsBaseWidget shuts down](http://hg.mozilla.org/mozilla-central/file/0df249a0e4d3/widget/nsBaseWidget.cpp#l182) - It calls nsBaseWidget::DestroyCompositor on the *Gecko Main Thread*.
|
||||
During nsBaseWidget::DestroyCompositor, it first destroys the CompositorChild.
|
||||
CompositorChild sends a sync IPC call to CompositorParent::RecvStop, which calls [CompositorParent::Destroy](http://hg.mozilla.org/mozilla-central/file/ab0490972e1e/gfx/layers/ipc/CompositorParent.cpp#l509).
|
||||
During nsBaseWidget::DestroyCompositor, it first destroys the CompositorBridgeChild.
|
||||
CompositorBridgeChild sends a sync IPC call to CompositorBridgeParent::RecvStop, which calls [CompositorBridgeParent::Destroy](http://hg.mozilla.org/mozilla-central/file/ab0490972e1e/gfx/layers/ipc/CompositorBridgeParent.cpp#l509).
|
||||
During this time, the *main thread* is blocked on the parent process.
|
||||
CompositorParent::RecvStop runs on the *Compositor thread* and cleans up some resources, including setting the **CompositorVsyncObserver** to nullptr.
|
||||
CompositorParent::RecvStop also explicitly keeps the CompositorParent alive and posts another task to run CompositorParent::DeferredDestroy on the Compositor loop so that all ipdl code can finish executing.
|
||||
CompositorBridgeParent::RecvStop runs on the *Compositor thread* and cleans up some resources, including setting the **CompositorVsyncObserver** to nullptr.
|
||||
CompositorBridgeParent::RecvStop also explicitly keeps the CompositorBridgeParent alive and posts another task to run CompositorBridgeParent::DeferredDestroy on the Compositor loop so that all ipdl code can finish executing.
|
||||
The **CompositorVsyncObserver** also unobserves from vsync and cancels any pending composite tasks.
|
||||
Once CompositorParent::RecvStop finishes, the *main thread* in the parent process continues shutting down the nsBaseWidget.
|
||||
Once CompositorBridgeParent::RecvStop finishes, the *main thread* in the parent process continues shutting down the nsBaseWidget.
|
||||
|
||||
At the same time, the *Compositor thread* is executing tasks until CompositorParent::DeferredDestroy runs, which flushes the compositor message loop.
|
||||
Now we have two tasks as both the nsBaseWidget releases a reference to the Compositor on the *main thread* during destruction and the CompositorParent::DeferredDestroy releases a reference to the CompositorParent on the *Compositor Thread*.
|
||||
Finally, the CompositorParent itself is destroyed on the *main thread* once both references are gone due to explicit [main thread destruction](http://hg.mozilla.org/mozilla-central/file/50b95032152c/gfx/layers/ipc/CompositorParent.h#l148).
|
||||
At the same time, the *Compositor thread* is executing tasks until CompositorBridgeParent::DeferredDestroy runs, which flushes the compositor message loop.
|
||||
Now we have two tasks as both the nsBaseWidget releases a reference to the Compositor on the *main thread* during destruction and the CompositorBridgeParent::DeferredDestroy releases a reference to the CompositorBridgeParent on the *Compositor Thread*.
|
||||
Finally, the CompositorBridgeParent itself is destroyed on the *main thread* once both references are gone due to explicit [main thread destruction](http://hg.mozilla.org/mozilla-central/file/50b95032152c/gfx/layers/ipc/CompositorBridgeParent.h#l148).
|
||||
|
||||
With the **CompositorVsyncObserver**, any accesses to the widget after nsBaseWidget::DestroyCompositor executes are invalid.
|
||||
Any accesses to the compositor between the time the nsBaseWidget::DestroyCompositor runs and the CompositorVsyncObserver's destructor runs aren't safe yet a hardware vsync event could occur between these times.
|
||||
Since any tasks posted on the Compositor loop after CompositorParent::DeferredDestroy is posted are invalid, we make sure that no vsync tasks can be posted once CompositorParent::RecvStop executes and DeferredDestroy is posted on the Compositor thread.
|
||||
When the sync call to CompositorParent::RecvStop executes, we explicitly set the CompositorVsyncObserver to null to prevent vsync notifications from occurring.
|
||||
If vsync notifications were allowed to occur, since the **CompositorVsyncObserver**'s vsync notification executes on the *hardware vsync thread*, it would post a task to the Compositor loop and may execute after CompositorParent::DeferredDestroy.
|
||||
Thus, we explicitly shut down vsync events in the **CompositorVsyncDispatcher** and **CompositorVsyncObserver** during nsBaseWidget::Shutdown to prevent any vsync tasks from executing after CompositorParent::DeferredDestroy.
|
||||
Since any tasks posted on the Compositor loop after CompositorBridgeParent::DeferredDestroy is posted are invalid, we make sure that no vsync tasks can be posted once CompositorBridgeParent::RecvStop executes and DeferredDestroy is posted on the Compositor thread.
|
||||
When the sync call to CompositorBridgeParent::RecvStop executes, we explicitly set the CompositorVsyncObserver to null to prevent vsync notifications from occurring.
|
||||
If vsync notifications were allowed to occur, since the **CompositorVsyncObserver**'s vsync notification executes on the *hardware vsync thread*, it would post a task to the Compositor loop and may execute after CompositorBridgeParent::DeferredDestroy.
|
||||
Thus, we explicitly shut down vsync events in the **CompositorVsyncDispatcher** and **CompositorVsyncObserver** during nsBaseWidget::Shutdown to prevent any vsync tasks from executing after CompositorBridgeParent::DeferredDestroy.
|
||||
|
||||
The **CompositorVsyncDispatcher** may be destroyed on either the *main thread* or *Compositor Thread*, since both the nsBaseWidget and **CompositorVsyncObserver** race to destroy on different threads.
|
||||
nsBaseWidget is destroyed on the *main thread* and releases a reference to the **CompositorVsyncDispatcher** during destruction.
|
||||
The **CompositorVsyncObserver** has a race to be destroyed either during CompositorParent shutdown or from the **GeckoTouchDispatcher** which is destroyed on the main thread with [ClearOnShutdown](http://hg.mozilla.org/mozilla-central/file/21567e9a6e40/xpcom/base/ClearOnShutdown.h#l15).
|
||||
Whichever object, the CompositorParent or the **GeckoTouchDispatcher** is destroyed last will hold the last reference to the **CompositorVsyncDispatcher**, which destroys the object.
|
||||
The **CompositorVsyncObserver** has a race to be destroyed either during CompositorBridgeParent shutdown or from the **GeckoTouchDispatcher** which is destroyed on the main thread with [ClearOnShutdown](http://hg.mozilla.org/mozilla-central/file/21567e9a6e40/xpcom/base/ClearOnShutdown.h#l15).
|
||||
Whichever object, the CompositorBridgeParent or the **GeckoTouchDispatcher** is destroyed last will hold the last reference to the **CompositorVsyncDispatcher**, which destroys the object.
|
||||
|
||||
#Refresh Driver
|
||||
The Refresh Driver is ticked from a [single active timer](http://hg.mozilla.org/mozilla-central/file/ab0490972e1e/layout/base/nsRefreshDriver.cpp#l11).
|
||||
@@ -212,7 +212,7 @@ There is still only one **VsyncParent/VsyncChild** pair, just each vsync notific
|
||||
|
||||
#Object Lifetime
|
||||
1. CompositorVsyncDispatcher - Lives as long as the nsBaseWidget associated with the VsyncDispatcher
|
||||
2. CompositorVsyncObserver - Lives and dies the same time as the CompositorParent.
|
||||
2. CompositorVsyncObserver - Lives and dies the same time as the CompositorBridgeParent.
|
||||
3. RefreshTimerVsyncDispatcher - As long as the associated display object, which is the lifetime of Firefox.
|
||||
4. VsyncSource - Lives as long as the gfxPlatform on the chrome process, which is the lifetime of Firefox.
|
||||
5. VsyncParent/VsyncChild - Lives as long as the content process
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "mozilla/layers/Compositor.h"
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent
|
||||
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "gfx2DGlue.h"
|
||||
@@ -25,8 +25,8 @@ namespace layers {
|
||||
/* static */ void
|
||||
Compositor::AssertOnCompositorThread()
|
||||
{
|
||||
MOZ_ASSERT(!CompositorParent::CompositorLoop() ||
|
||||
CompositorParent::CompositorLoop() == MessageLoop::current(),
|
||||
MOZ_ASSERT(!CompositorBridgeParent::CompositorLoop() ||
|
||||
CompositorBridgeParent::CompositorLoop() == MessageLoop::current(),
|
||||
"Can only call this from the compositor thread!");
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class Layer;
|
||||
class TextureSource;
|
||||
class DataTextureSource;
|
||||
class CompositingRenderTarget;
|
||||
class CompositorParent;
|
||||
class CompositorBridgeParent;
|
||||
class LayerManagerComposite;
|
||||
|
||||
enum SurfaceInitMode
|
||||
@@ -184,7 +184,7 @@ protected:
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(Compositor)
|
||||
|
||||
explicit Compositor(CompositorParent* aParent = nullptr)
|
||||
explicit Compositor(CompositorBridgeParent* aParent = nullptr)
|
||||
: mCompositorID(0)
|
||||
, mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC)
|
||||
, mParent(aParent)
|
||||
@@ -549,7 +549,7 @@ protected:
|
||||
|
||||
uint32_t mCompositorID;
|
||||
DiagnosticTypes mDiagnosticTypes;
|
||||
CompositorParent* mParent;
|
||||
CompositorBridgeParent* mParent;
|
||||
|
||||
/**
|
||||
* We keep track of the total number of pixels filled as we composite the
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "TexturePoolOGL.h"
|
||||
#include "mozilla/layers/CompositorOGL.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/TextureHostOGL.h"
|
||||
|
||||
@@ -1900,7 +1900,7 @@ bool
|
||||
LayerScope::CheckSendable()
|
||||
{
|
||||
// Only compositor threads check LayerScope status
|
||||
MOZ_ASSERT(CompositorParent::IsInCompositorThread() || gIsGtest);
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread() || gIsGtest);
|
||||
|
||||
if (!gfxPrefs::LayerScopeEnabled()) {
|
||||
return false;
|
||||
|
||||
+32
-10
@@ -1710,7 +1710,8 @@ void WriteSnapshotToDumpFile(Compositor* aCompositor, DrawTarget* aTarget)
|
||||
#endif
|
||||
|
||||
void
|
||||
Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml)
|
||||
Layer::Dump(std::stringstream& aStream, const char* aPrefix,
|
||||
bool aDumpHtml, bool aSorted)
|
||||
{
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
bool dumpCompositorTexture = gfxEnv::DumpCompositorTextures() && AsLayerComposite() &&
|
||||
@@ -1777,13 +1778,25 @@ Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Layer* kid = GetFirstChild()) {
|
||||
if (ContainerLayer* container = AsContainerLayer()) {
|
||||
AutoTArray<Layer*, 12> children;
|
||||
if (aSorted) {
|
||||
container->SortChildrenBy3DZOrder(children);
|
||||
} else {
|
||||
for (Layer* l = container->GetFirstChild(); l; l = l->GetNextSibling()) {
|
||||
children.AppendElement(l);
|
||||
}
|
||||
}
|
||||
nsAutoCString pfx(aPrefix);
|
||||
pfx += " ";
|
||||
if (aDumpHtml) {
|
||||
aStream << "<ul>";
|
||||
}
|
||||
kid->Dump(aStream, pfx.get(), aDumpHtml);
|
||||
|
||||
for (Layer* child : children) {
|
||||
child->Dump(aStream, pfx.get(), aDumpHtml, aSorted);
|
||||
}
|
||||
|
||||
if (aDumpHtml) {
|
||||
aStream << "</ul>";
|
||||
}
|
||||
@@ -1792,8 +1805,6 @@ Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml)
|
||||
if (aDumpHtml) {
|
||||
aStream << "</li>";
|
||||
}
|
||||
if (Layer* next = GetNextSibling())
|
||||
next->Dump(aStream, aPrefix, aDumpHtml);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1927,6 +1938,15 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
||||
if (GetContentFlags() & CONTENT_BACKFACE_HIDDEN) {
|
||||
aStream << " [backfaceHidden]";
|
||||
}
|
||||
if (Extend3DContext()) {
|
||||
aStream << " [extend3DContext]";
|
||||
}
|
||||
if (Combines3DTransformWithAncestors()) {
|
||||
aStream << " [combines3DTransformWithAncestors]";
|
||||
}
|
||||
if (Is3DContextLeaf()) {
|
||||
aStream << " [is3DContextLeaf]";
|
||||
}
|
||||
if (GetScrollbarDirection() == VERTICAL) {
|
||||
aStream << nsPrintfCString(" [vscrollbar=%lld]", GetScrollbarTargetContainerId()).get();
|
||||
}
|
||||
@@ -2317,14 +2337,15 @@ ReadbackLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent
|
||||
// LayerManager
|
||||
|
||||
void
|
||||
LayerManager::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml)
|
||||
LayerManager::Dump(std::stringstream& aStream, const char* aPrefix,
|
||||
bool aDumpHtml, bool aSorted)
|
||||
{
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (aDumpHtml) {
|
||||
aStream << "<ul><li>";
|
||||
}
|
||||
#endif
|
||||
DumpSelf(aStream, aPrefix);
|
||||
DumpSelf(aStream, aPrefix, aSorted);
|
||||
|
||||
nsAutoCString pfx(aPrefix);
|
||||
pfx += " ";
|
||||
@@ -2347,17 +2368,18 @@ LayerManager::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHt
|
||||
}
|
||||
|
||||
void
|
||||
LayerManager::DumpSelf(std::stringstream& aStream, const char* aPrefix)
|
||||
LayerManager::DumpSelf(std::stringstream& aStream, const char* aPrefix, bool aSorted)
|
||||
{
|
||||
PrintInfo(aStream, aPrefix);
|
||||
aStream << " --- in " << (aSorted ? "3D-sorted rendering order" : "content order");
|
||||
aStream << "\n";
|
||||
}
|
||||
|
||||
void
|
||||
LayerManager::Dump()
|
||||
LayerManager::Dump(bool aSorted)
|
||||
{
|
||||
std::stringstream ss;
|
||||
Dump(ss);
|
||||
Dump(ss, "", false, aSorted);
|
||||
print_stderr(ss);
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -564,12 +564,13 @@ public:
|
||||
* Dump information about this layer manager and its managed tree to
|
||||
* aStream.
|
||||
*/
|
||||
void Dump(std::stringstream& aStream, const char* aPrefix="", bool aDumpHtml=false);
|
||||
void Dump(std::stringstream& aStream, const char* aPrefix="",
|
||||
bool aDumpHtml=false, bool aSorted=false);
|
||||
/**
|
||||
* Dump information about just this layer manager itself to aStream
|
||||
*/
|
||||
void DumpSelf(std::stringstream& aStream, const char* aPrefix="");
|
||||
void Dump();
|
||||
void DumpSelf(std::stringstream& aStream, const char* aPrefix="", bool aSorted=false);
|
||||
void Dump(bool aSorted=false);
|
||||
|
||||
/**
|
||||
* Dump information about this layer manager and its managed tree to
|
||||
@@ -1587,7 +1588,8 @@ public:
|
||||
* Dump information about this layer manager and its managed tree to
|
||||
* aStream.
|
||||
*/
|
||||
void Dump(std::stringstream& aStream, const char* aPrefix="", bool aDumpHtml=false);
|
||||
void Dump(std::stringstream& aStream, const char* aPrefix="",
|
||||
bool aDumpHtml=false, bool aSorted=false);
|
||||
/**
|
||||
* Dump information about just this layer manager itself to aStream.
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnCompositorThread, etc
|
||||
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
|
||||
#include "mozilla/layers/AsyncDragMetrics.h" // for AsyncDragMetrics
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent, etc
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent, etc
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/mozalloc.h" // for operator new
|
||||
@@ -54,7 +54,7 @@ typedef mozilla::gfx::Matrix4x4 Matrix4x4;
|
||||
float APZCTreeManager::sDPI = 160.0;
|
||||
|
||||
struct APZCTreeManager::TreeBuildingState {
|
||||
TreeBuildingState(CompositorParent* aCompositor,
|
||||
TreeBuildingState(CompositorBridgeParent* aCompositor,
|
||||
bool aIsFirstPaint, uint64_t aOriginatingLayersId,
|
||||
APZTestData* aTestData, uint32_t aPaintSequence)
|
||||
: mCompositor(aCompositor)
|
||||
@@ -65,7 +65,7 @@ struct APZCTreeManager::TreeBuildingState {
|
||||
}
|
||||
|
||||
// State that doesn't change as we recurse in the tree building
|
||||
CompositorParent* const mCompositor;
|
||||
CompositorBridgeParent* const mCompositor;
|
||||
const bool mIsFirstPaint;
|
||||
const uint64_t mOriginatingLayersId;
|
||||
const APZPaintLogHelper mPaintLogger;
|
||||
@@ -130,7 +130,7 @@ APZCTreeManager::SetAllowedTouchBehavior(uint64_t aInputBlockId,
|
||||
}
|
||||
|
||||
void
|
||||
APZCTreeManager::UpdateHitTestingTree(CompositorParent* aCompositor,
|
||||
APZCTreeManager::UpdateHitTestingTree(CompositorBridgeParent* aCompositor,
|
||||
Layer* aRoot,
|
||||
bool aIsFirstPaint,
|
||||
uint64_t aOriginatingLayersId,
|
||||
@@ -144,7 +144,7 @@ APZCTreeManager::UpdateHitTestingTree(CompositorParent* aCompositor,
|
||||
// the layers id that originated this update.
|
||||
APZTestData* testData = nullptr;
|
||||
if (gfxPrefs::APZTestLoggingEnabled()) {
|
||||
if (CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aOriginatingLayersId)) {
|
||||
if (CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(aOriginatingLayersId)) {
|
||||
testData = &state->mApzTestData;
|
||||
testData->StartNewPaint(aPaintSequenceNumber);
|
||||
}
|
||||
@@ -350,7 +350,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
|
||||
needsApzc = false;
|
||||
}
|
||||
|
||||
const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aLayersId);
|
||||
const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(aLayersId);
|
||||
if (!(state && state->mController.get())) {
|
||||
needsApzc = false;
|
||||
}
|
||||
@@ -437,7 +437,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
|
||||
bool newApzc = (apzc == nullptr || apzc->IsDestroyed());
|
||||
if (newApzc) {
|
||||
apzc = NewAPZCInstance(aLayersId, state->mController);
|
||||
apzc->SetCompositorParent(aState.mCompositor);
|
||||
apzc->SetCompositorBridgeParent(aState.mCompositor);
|
||||
if (state->mCrossProcessParent != nullptr) {
|
||||
apzc->ShareFrameMetricsAcrossProcesses();
|
||||
}
|
||||
@@ -642,7 +642,8 @@ APZCTreeManager::FlushApzRepaints(uint64_t aLayersId)
|
||||
// ensure any pending paints were flushed. Now, paints are flushed
|
||||
// immediately, so it is safe to simply send a notification now.
|
||||
APZCTM_LOG("Flushing repaints for layers id %" PRIu64, aLayersId);
|
||||
const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aLayersId);
|
||||
const CompositorBridgeParent::LayerTreeState* state =
|
||||
CompositorBridgeParent::GetIndirectShadowTree(aLayersId);
|
||||
MOZ_ASSERT(state && state->mController);
|
||||
NS_DispatchToMainThread(NS_NewRunnableMethod(
|
||||
state->mController.get(), &GeckoContentController::NotifyFlushComplete));
|
||||
|
||||
@@ -50,7 +50,7 @@ enum ZoomToRectBehavior : uint32_t {
|
||||
class Layer;
|
||||
class AsyncDragMetrics;
|
||||
class AsyncPanZoomController;
|
||||
class CompositorParent;
|
||||
class CompositorBridgeParent;
|
||||
class OverscrollHandoffChain;
|
||||
struct OverscrollHandoffState;
|
||||
struct FlingHandoffState;
|
||||
@@ -77,7 +77,7 @@ class HitTestingTreeNode;
|
||||
|
||||
/**
|
||||
* This class manages the tree of AsyncPanZoomController instances. There is one
|
||||
* instance of this class owned by each CompositorParent, and it contains as
|
||||
* instance of this class owned by each CompositorBridgeParent, and it contains as
|
||||
* many AsyncPanZoomController instances as there are scrollable container layers.
|
||||
* This class generally lives on the compositor thread, although some functions
|
||||
* may be called from other threads as noted; thread safety is ensured internally.
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
* process' layer subtree has its own sequence
|
||||
* numbers.
|
||||
*/
|
||||
void UpdateHitTestingTree(CompositorParent* aCompositor,
|
||||
void UpdateHitTestingTree(CompositorBridgeParent* aCompositor,
|
||||
Layer* aRoot,
|
||||
bool aIsFirstPaint,
|
||||
uint64_t aOriginatingLayersId,
|
||||
|
||||
@@ -51,9 +51,8 @@
|
||||
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
|
||||
#include "mozilla/layers/AxisPhysicsModel.h" // for AxisPhysicsModel
|
||||
#include "mozilla/layers/AxisPhysicsMSDModel.h" // for AxisPhysicsMSDModel
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent
|
||||
#include "mozilla/layers/LayerTransactionParent.h" // for LayerTransactionParent
|
||||
#include "mozilla/layers/PCompositorBridgeParent.h" // for PCompositorBridgeParent
|
||||
#include "mozilla/layers/ScrollInputMethods.h" // for ScrollInputMethod
|
||||
#include "mozilla/mozalloc.h" // for operator new, etc
|
||||
#include "mozilla/unused.h" // for unused
|
||||
@@ -890,13 +889,13 @@ AsyncPanZoomController::GetSharedFrameMetricsCompositor()
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
|
||||
if (mSharingFrameMetricsAcrossProcesses) {
|
||||
// |state| may be null here if the CrossProcessCompositorParent has already been destroyed.
|
||||
if (const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(mLayersId)) {
|
||||
// |state| may be null here if the CrossProcessCompositorBridgeParent has already been destroyed.
|
||||
if (const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(mLayersId)) {
|
||||
return state->CrossProcessPCompositorBridge();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
return mCompositorParent.get();
|
||||
return mCompositorBridgeParent.get();
|
||||
}
|
||||
|
||||
already_AddRefed<GeckoContentController>
|
||||
@@ -2668,8 +2667,8 @@ void AsyncPanZoomController::ClearOverscroll() {
|
||||
mY.ClearOverscroll();
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::SetCompositorParent(CompositorParent* aCompositorParent) {
|
||||
mCompositorParent = aCompositorParent;
|
||||
void AsyncPanZoomController::SetCompositorBridgeParent(CompositorBridgeParent* aCompositorBridgeParent) {
|
||||
mCompositorBridgeParent = aCompositorBridgeParent;
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::ShareFrameMetricsAcrossProcesses() {
|
||||
@@ -2810,8 +2809,8 @@ const ScreenMargin AsyncPanZoomController::CalculatePendingDisplayPort(
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::ScheduleComposite() {
|
||||
if (mCompositorParent) {
|
||||
mCompositorParent->ScheduleRenderOnCompositorThread();
|
||||
if (mCompositorBridgeParent) {
|
||||
mCompositorBridgeParent->ScheduleRenderOnCompositorThread();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3684,16 +3683,16 @@ void AsyncPanZoomController::DispatchStateChangeNotification(PanZoomState aOldSt
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
||||
// Let the compositor know about scroll state changes so it can manage
|
||||
// windowed plugins.
|
||||
if (mCompositorParent) {
|
||||
mCompositorParent->ScheduleHideAllPluginWindows();
|
||||
if (mCompositorBridgeParent) {
|
||||
mCompositorBridgeParent->ScheduleHideAllPluginWindows();
|
||||
}
|
||||
#endif
|
||||
} else if (IsTransformingState(aOldState) && !IsTransformingState(aNewState)) {
|
||||
controller->NotifyAPZStateChange(
|
||||
GetGuid(), APZStateChange::TransformEnd);
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
||||
if (mCompositorParent) {
|
||||
mCompositorParent->ScheduleShowAllPluginWindows();
|
||||
if (mCompositorBridgeParent) {
|
||||
mCompositorBridgeParent->ScheduleShowAllPluginWindows();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace layers {
|
||||
|
||||
class AsyncDragMetrics;
|
||||
struct ScrollableLayerGuid;
|
||||
class CompositorParent;
|
||||
class CompositorBridgeParent;
|
||||
class GestureEventListener;
|
||||
class PCompositorBridgeParent;
|
||||
struct AsyncTransform;
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
* The platform implementation must set the compositor parent so that we can
|
||||
* request composites.
|
||||
*/
|
||||
void SetCompositorParent(CompositorParent* aCompositorParent);
|
||||
void SetCompositorBridgeParent(CompositorBridgeParent* aCompositorBridgeParent);
|
||||
|
||||
/**
|
||||
* Inform this APZC that it will be sharing its FrameMetrics with a cross-process
|
||||
@@ -508,7 +508,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Schedules a composite on the compositor thread. Wrapper for
|
||||
* CompositorParent::ScheduleRenderOnCompositorThread().
|
||||
* CompositorBridgeParent::ScheduleRenderOnCompositorThread().
|
||||
*/
|
||||
void ScheduleComposite();
|
||||
|
||||
@@ -650,7 +650,7 @@ protected:
|
||||
void RequestSnapToDestination();
|
||||
|
||||
uint64_t mLayersId;
|
||||
RefPtr<CompositorParent> mCompositorParent;
|
||||
RefPtr<CompositorBridgeParent> mCompositorBridgeParent;
|
||||
|
||||
/* Access to the following two fields is protected by the mRefPtrMonitor,
|
||||
since they are accessed on the UI thread but can be cleared on the
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
|
||||
#include "mozilla/layers/GeckoContentController.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h"
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
<script type="application/javascript">
|
||||
|
||||
function scrollPage() {
|
||||
SpecialPowers._addMessageListener("APZ:TransformEnd", function() {
|
||||
var transformEnd = function() {
|
||||
SpecialPowers.Services.obs.removeObserver(transformEnd, "APZ:TransformEnd", false);
|
||||
dump("Transform complete; flushing repaints...\n");
|
||||
flushApzRepaints(checkScroll);
|
||||
});
|
||||
};
|
||||
SpecialPowers.Services.obs.addObserver(transformEnd, "APZ:TransformEnd", false);
|
||||
|
||||
const TOUCH_SLOP = 1;
|
||||
synthesizeNativeDrag(document.body, 10, 100, 0, -(50 + TOUCH_SLOP));
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
<script type="application/javascript">
|
||||
|
||||
function scrollOuter() {
|
||||
SpecialPowers._addMessageListener("APZ:TransformEnd", function() {
|
||||
var transformEnd = function() {
|
||||
SpecialPowers.Services.obs.removeObserver(transformEnd, "APZ:TransformEnd", false);
|
||||
dump("Transform complete; flushing repaints...\n");
|
||||
flushApzRepaints(checkScroll);
|
||||
});
|
||||
};
|
||||
SpecialPowers.Services.obs.addObserver(transformEnd, "APZ:TransformEnd", false);
|
||||
|
||||
const TOUCH_SLOP = 1;
|
||||
synthesizeNativeDrag(document.getElementById('outer'), 10, 100, 0, -(50 + TOUCH_SLOP));
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
|
||||
function scrollOuter() {
|
||||
var outer = document.getElementById('outer');
|
||||
SpecialPowers._addMessageListener("APZ:TransformEnd", function() {
|
||||
var transformEnd = function() {
|
||||
SpecialPowers.Services.obs.removeObserver(transformEnd, "APZ:TransformEnd", false);
|
||||
dump("Transform complete; flushing repaints...\n");
|
||||
flushApzRepaints(checkScroll, outer.contentWindow);
|
||||
});
|
||||
};
|
||||
SpecialPowers.Services.obs.addObserver(transformEnd, "APZ:TransformEnd", false);
|
||||
|
||||
const TOUCH_SLOP = 1;
|
||||
synthesizeNativeDrag(outer.contentDocument.body, 10, 100, 0, -(50 + TOUCH_SLOP));
|
||||
|
||||
@@ -19,7 +19,9 @@ skip-if = (os == 'android') || (os == 'b2g') # wheel events not supported on mob
|
||||
[test_layerization.html]
|
||||
skip-if = (os == 'android') || (os == 'b2g') # uses wheel events which are not supported on mobile
|
||||
[test_basic_pan.html]
|
||||
skip-if = toolkit != 'gonk'
|
||||
# Windows touch injection doesn't work in automation, but this test can be run locally on a windows touch device.
|
||||
# On OS X we don't support touch events at all.
|
||||
skip-if = (toolkit == 'windows') || (toolkit == 'cocoa')
|
||||
[test_scroll_inactive_flattened_frame.html]
|
||||
skip-if = (os == 'android') || (os == 'b2g') || (buildapp == 'mulet') # wheel events not supported on mobile; see bug 1164274 for mulet
|
||||
[test_scroll_inactive_bug1190112.html]
|
||||
|
||||
@@ -34,6 +34,16 @@ function testDone() {
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
if (!SpecialPowers.getDOMWindowUtils(window).asyncPanZoomEnabled) {
|
||||
ok(true, "APZ is not enabled, this test is not relevant, sorry!\n");
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
if (!window.TouchEvent) {
|
||||
ok(true, "Touch events are not supported on this platform, sorry!\n");
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{ "set":
|
||||
[
|
||||
@@ -45,6 +55,10 @@ window.onload = function() {
|
||||
// events get held up. Try to prevent that by making long-taps require
|
||||
// a 10 second hold.
|
||||
["ui.click_hold_context_menus.delay", "10000"],
|
||||
// The subtests in this test do touch-drags to pan the page, but we don't
|
||||
// want those pans to turn into fling animations, so we increase the
|
||||
// fling-stop threshold velocity to absurdly high.
|
||||
["apz.fling_stopped_threshold", "10000"],
|
||||
]
|
||||
}, testDone);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "MainThreadUtils.h" // for NS_IsMainThread()
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/APZCCallbackHelper.h"
|
||||
#include "mozilla/layers/APZEventState.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "mozilla/layers/BufferTexture.h"
|
||||
#include "mozilla/layers/AsyncCanvasRenderer.h"
|
||||
#include "mozilla/layers/CompositableForwarder.h"
|
||||
#include "mozilla/layers/CompositorChild.h" // for CompositorChild
|
||||
#include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild
|
||||
#include "mozilla/layers/GrallocTextureClient.h"
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "mozilla/dom/TabChild.h" // for TabChild
|
||||
#include "mozilla/hal_sandbox/PHal.h" // for ScreenConfiguration
|
||||
#include "mozilla/layers/CompositableClient.h"
|
||||
#include "mozilla/layers/CompositorChild.h" // for CompositorChild
|
||||
#include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild
|
||||
#include "mozilla/layers/ContentClient.h"
|
||||
#include "mozilla/layers/FrameUniformityData.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
@@ -120,7 +120,7 @@ ClientLayerManager::~ClientLayerManager()
|
||||
// After the call, the message is directly handled by LayerTransactionChild.
|
||||
// Basically this function should be called in ShadowLayerForwarder's
|
||||
// destructor. But when the destructor is triggered by
|
||||
// CompositorChild::Destroy(), the destructor can not handle it correctly.
|
||||
// CompositorBridgeChild::Destroy(), the destructor can not handle it correctly.
|
||||
// See Bug 1000525.
|
||||
mForwarder->StopReceiveAsyncParentMessge();
|
||||
mRoot = nullptr;
|
||||
@@ -369,7 +369,7 @@ ClientLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags)
|
||||
return true;
|
||||
}
|
||||
|
||||
CompositorChild *
|
||||
CompositorBridgeChild *
|
||||
ClientLayerManager::GetRemoteRenderer()
|
||||
{
|
||||
if (!mWidget) {
|
||||
@@ -379,11 +379,11 @@ ClientLayerManager::GetRemoteRenderer()
|
||||
return mWidget->GetRemoteRenderer();
|
||||
}
|
||||
|
||||
CompositorChild*
|
||||
ClientLayerManager::GetCompositorChild()
|
||||
CompositorBridgeChild*
|
||||
ClientLayerManager::GetCompositorBridgeChild()
|
||||
{
|
||||
if (!XRE_IsParentProcess()) {
|
||||
return CompositorChild::Get();
|
||||
return CompositorBridgeChild::Get();
|
||||
}
|
||||
return GetRemoteRenderer();
|
||||
}
|
||||
@@ -458,7 +458,7 @@ ClientLayerManager::GetFrameUniformity(FrameUniformityData* aOutData)
|
||||
MOZ_ASSERT(XRE_IsParentProcess(), "Frame Uniformity only supported in parent process");
|
||||
|
||||
if (HasShadowManager()) {
|
||||
CompositorChild* child = GetRemoteRenderer();
|
||||
CompositorBridgeChild* child = GetRemoteRenderer();
|
||||
child->SendGetFrameUniformity(aOutData);
|
||||
return;
|
||||
}
|
||||
@@ -473,8 +473,8 @@ ClientLayerManager::RequestOverfill(mozilla::dom::OverfillCallback* aCallback)
|
||||
MOZ_ASSERT(HasShadowManager(), "Request Overfill only supported on b2g for now");
|
||||
|
||||
if (HasShadowManager()) {
|
||||
CompositorChild* child = GetRemoteRenderer();
|
||||
NS_ASSERTION(child, "Could not get CompositorChild");
|
||||
CompositorBridgeChild* child = GetRemoteRenderer();
|
||||
NS_ASSERTION(child, "Could not get CompositorBridgeChild");
|
||||
|
||||
child->AddOverfillObserver(this);
|
||||
child->SendRequestOverfill();
|
||||
@@ -502,7 +502,7 @@ ClientLayerManager::MakeSnapshotIfRequired()
|
||||
return;
|
||||
}
|
||||
if (mWidget) {
|
||||
if (CompositorChild* remoteRenderer = GetRemoteRenderer()) {
|
||||
if (CompositorBridgeChild* remoteRenderer = GetRemoteRenderer()) {
|
||||
// The compositor doesn't draw to a different sized surface
|
||||
// when there's a rotation. Instead we rotate the result
|
||||
// when drawing into dt
|
||||
@@ -549,7 +549,7 @@ void
|
||||
ClientLayerManager::FlushRendering()
|
||||
{
|
||||
if (mWidget) {
|
||||
if (CompositorChild* remoteRenderer = mWidget->GetRemoteRenderer()) {
|
||||
if (CompositorBridgeChild* remoteRenderer = mWidget->GetRemoteRenderer()) {
|
||||
remoteRenderer->SendFlushRendering();
|
||||
}
|
||||
}
|
||||
@@ -565,7 +565,7 @@ void
|
||||
ClientLayerManager::SendInvalidRegion(const nsIntRegion& aRegion)
|
||||
{
|
||||
if (mWidget) {
|
||||
if (CompositorChild* remoteRenderer = mWidget->GetRemoteRenderer()) {
|
||||
if (CompositorBridgeChild* remoteRenderer = mWidget->GetRemoteRenderer()) {
|
||||
remoteRenderer->SendNotifyRegionInvalidated(aRegion);
|
||||
}
|
||||
}
|
||||
@@ -574,7 +574,7 @@ ClientLayerManager::SendInvalidRegion(const nsIntRegion& aRegion)
|
||||
uint32_t
|
||||
ClientLayerManager::StartFrameTimeRecording(int32_t aBufferSize)
|
||||
{
|
||||
CompositorChild* renderer = GetRemoteRenderer();
|
||||
CompositorBridgeChild* renderer = GetRemoteRenderer();
|
||||
if (renderer) {
|
||||
uint32_t startIndex;
|
||||
renderer->SendStartFrameTimeRecording(aBufferSize, &startIndex);
|
||||
@@ -587,7 +587,7 @@ void
|
||||
ClientLayerManager::StopFrameTimeRecording(uint32_t aStartIndex,
|
||||
nsTArray<float>& aFrameIntervals)
|
||||
{
|
||||
CompositorChild* renderer = GetRemoteRenderer();
|
||||
CompositorBridgeChild* renderer = GetRemoteRenderer();
|
||||
if (renderer) {
|
||||
renderer->SendStopFrameTimeRecording(aStartIndex, &aFrameIntervals);
|
||||
}
|
||||
@@ -794,7 +794,7 @@ ClientLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
MOZ_ASSERT(aMetrics.IsScrollable());
|
||||
// This is derived from the code in
|
||||
// gfx/layers/ipc/CompositorParent.cpp::TransformShadowTree.
|
||||
// gfx/layers/ipc/CompositorBridgeParent.cpp::TransformShadowTree.
|
||||
CSSToLayerScale paintScale = aMetrics.LayersPixelsPerCSSPixel().ToScaleFactor();
|
||||
const CSSRect& metricsDisplayPort =
|
||||
(aDrawingCritical && !aMetrics.GetCriticalDisplayPort().IsEmpty()) ?
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class ClientPaintedLayer;
|
||||
class CompositorChild;
|
||||
class CompositorBridgeChild;
|
||||
class ImageLayer;
|
||||
class PLayerChild;
|
||||
class FrameUniformityData;
|
||||
@@ -158,9 +158,9 @@ public:
|
||||
void* GetPaintedLayerCallbackData() const
|
||||
{ return mPaintedLayerCallbackData; }
|
||||
|
||||
CompositorChild* GetRemoteRenderer();
|
||||
CompositorBridgeChild* GetRemoteRenderer();
|
||||
|
||||
CompositorChild* GetCompositorChild();
|
||||
CompositorBridgeChild* GetCompositorBridgeChild();
|
||||
|
||||
// Disable component alpha layers with the software compositor.
|
||||
virtual bool ShouldAvoidComponentAlphaLayers() override { return !IsCompositingCheap(); }
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
||||
#include "mozilla/gfx/Rect.h" // for Rect, RectTyped
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
||||
#include "mozilla/layers/LayersMessages.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
@@ -215,9 +215,9 @@ ClientTiledPaintedLayer::BeginPaint()
|
||||
bool
|
||||
ClientTiledPaintedLayer::IsScrollingOnCompositor(const FrameMetrics& aParentMetrics)
|
||||
{
|
||||
CompositorChild* compositor = nullptr;
|
||||
CompositorBridgeChild* compositor = nullptr;
|
||||
if (Manager() && Manager()->AsClientLayerManager()) {
|
||||
compositor = Manager()->AsClientLayerManager()->GetCompositorChild();
|
||||
compositor = Manager()->AsClientLayerManager()->GetCompositorBridgeChild();
|
||||
}
|
||||
|
||||
if (!compositor) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/layers/CompositorChild.h" // for CompositorChild
|
||||
#include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/LayersMessages.h" // for ThebesBufferData
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
|
||||
@@ -979,7 +979,7 @@ TextureClient::RemoveFromCompositable(CompositableClient* aCompositable,
|
||||
// Hold TextureClient until transaction complete.
|
||||
tracker->SetTextureClient(this);
|
||||
mRemoveFromCompositableWaiter = waiter;
|
||||
// RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
|
||||
// RemoveTextureFromCompositableAsync() expects CompositorBridgeChild's presence.
|
||||
mActor->GetForwarder()->RemoveTextureFromCompositableAsync(tracker, aCompositable, this);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/gfx/Tools.h" // for BytesPerPixel
|
||||
#include "mozilla/layers/CompositableForwarder.h"
|
||||
#include "mozilla/layers/CompositorChild.h" // for CompositorChild
|
||||
#include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h"
|
||||
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
|
||||
#include "TextureClientPool.h"
|
||||
@@ -167,10 +167,10 @@ SharedFrameMetricsHelper::UpdateFromCompositorFrameMetrics(
|
||||
{
|
||||
MOZ_ASSERT(aLayer);
|
||||
|
||||
CompositorChild* compositor = nullptr;
|
||||
CompositorBridgeChild* compositor = nullptr;
|
||||
if (aLayer.Manager() &&
|
||||
aLayer.Manager()->AsClientLayerManager()) {
|
||||
compositor = aLayer.Manager()->AsClientLayerManager()->GetCompositorChild();
|
||||
compositor = aLayer.Manager()->AsClientLayerManager()->GetCompositorBridgeChild();
|
||||
}
|
||||
|
||||
if (!compositor) {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
|
||||
#include "mozilla/layers/APZUtils.h" // for CompleteAsyncTransform
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent, etc
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent, etc
|
||||
#include "mozilla/layers/LayerAnimationUtils.h" // for TimingFunctionToComputedTimingFunction
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
||||
#include "nsCoord.h" // for NSAppUnitsToFloatPixels, etc
|
||||
@@ -74,14 +74,14 @@ static void
|
||||
WalkTheTree(Layer* aLayer,
|
||||
bool& aReady,
|
||||
const TargetConfig& aTargetConfig,
|
||||
CompositorParent* aCompositor,
|
||||
CompositorBridgeParent* aCompositor,
|
||||
bool& aHasRemote,
|
||||
bool aWillResolvePlugins,
|
||||
bool& aDidResolvePlugins)
|
||||
{
|
||||
if (RefLayer* ref = aLayer->AsRefLayer()) {
|
||||
aHasRemote = true;
|
||||
if (const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(ref->GetReferentId())) {
|
||||
if (const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(ref->GetReferentId())) {
|
||||
if (Layer* referent = state->mRoot) {
|
||||
if (!ref->GetLocalVisibleRegion().IsEmpty()) {
|
||||
dom::ScreenOrientationInternal chromeOrientation = aTargetConfig.orientation();
|
||||
@@ -131,7 +131,7 @@ AsyncCompositionManager::~AsyncCompositionManager()
|
||||
}
|
||||
|
||||
void
|
||||
AsyncCompositionManager::ResolveRefLayers(CompositorParent* aCompositor,
|
||||
AsyncCompositionManager::ResolveRefLayers(CompositorBridgeParent* aCompositor,
|
||||
bool* aHasRemoteContent,
|
||||
bool* aResolvePlugins)
|
||||
{
|
||||
@@ -174,7 +174,7 @@ AsyncCompositionManager::DetachRefLayers()
|
||||
if (!mLayerManager->GetRoot()) {
|
||||
return;
|
||||
}
|
||||
CompositorParent* dummy = nullptr;
|
||||
CompositorBridgeParent* dummy = nullptr;
|
||||
bool ignored = false;
|
||||
WalkTheTree<Detach>(mLayerManager->GetRoot(),
|
||||
mReadyForCompose,
|
||||
@@ -679,7 +679,7 @@ void
|
||||
AsyncCompositionManager::RecordShadowTransforms(Layer* aLayer)
|
||||
{
|
||||
MOZ_ASSERT(gfxPrefs::CollectScrollTransforms());
|
||||
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
|
||||
for (Layer* child = aLayer->GetFirstChild();
|
||||
child; child = child->GetNextSibling()) {
|
||||
@@ -1363,7 +1363,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer)
|
||||
void
|
||||
AsyncCompositionManager::GetFrameUniformity(FrameUniformityData* aOutData)
|
||||
{
|
||||
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
mLayerTransformRecorder.EndTest(aOutData);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class AsyncPanZoomController;
|
||||
class Layer;
|
||||
class LayerManagerComposite;
|
||||
class AutoResolveRefLayers;
|
||||
class CompositorParent;
|
||||
class CompositorBridgeParent;
|
||||
|
||||
// Represents async transforms consisting of a scale and a translation.
|
||||
struct AsyncTransform {
|
||||
@@ -194,7 +194,7 @@ private:
|
||||
* to linux and windows only, may be null. On return value indicates
|
||||
* if any updates occured.
|
||||
*/
|
||||
void ResolveRefLayers(CompositorParent* aCompositor, bool* aHasRemoteContent,
|
||||
void ResolveRefLayers(CompositorBridgeParent* aCompositor, bool* aHasRemoteContent,
|
||||
bool* aResolvePlugins);
|
||||
|
||||
/**
|
||||
@@ -243,7 +243,7 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AsyncCompositionManager::TransformsToSkip)
|
||||
class MOZ_STACK_CLASS AutoResolveRefLayers {
|
||||
public:
|
||||
explicit AutoResolveRefLayers(AsyncCompositionManager* aManager,
|
||||
CompositorParent* aCompositor = nullptr,
|
||||
CompositorBridgeParent* aCompositor = nullptr,
|
||||
bool* aHasRemoteContent = nullptr,
|
||||
bool* aResolvePlugins = nullptr) :
|
||||
mManager(aManager)
|
||||
|
||||
@@ -841,7 +841,7 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion)
|
||||
|
||||
// Dump to console
|
||||
if (gfxPrefs::LayersDump()) {
|
||||
this->Dump();
|
||||
this->Dump(/* aSorted= */true);
|
||||
} else if (profiler_feature_active("layersdump")) {
|
||||
std::stringstream ss;
|
||||
Dump(ss);
|
||||
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
return mCompositor;
|
||||
}
|
||||
|
||||
// Called by CompositorParent when a new compositor has been created due
|
||||
// Called by CompositorBridgeParent when a new compositor has been created due
|
||||
// to a device reset. The layer manager must clear any cached resources
|
||||
// attached to the old compositor, and make a best effort at ignoring
|
||||
// layer or texture updates against the old compositor.
|
||||
|
||||
@@ -13,18 +13,17 @@
|
||||
#include "nsWindowsHelpers.h"
|
||||
#include "Nv3DVUtils.h"
|
||||
#include "gfxFailure.h"
|
||||
#include "mozilla/layers/PCompositorBridgeParent.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "gfxCrashReporterUtils.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
CompositorD3D9::CompositorD3D9(CompositorParent* aParent, nsIWidget *aWidget)
|
||||
CompositorD3D9::CompositorD3D9(CompositorBridgeParent* aParent, nsIWidget *aWidget)
|
||||
: Compositor(aParent)
|
||||
, mWidget(aWidget)
|
||||
, mDeviceResetCount(0)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace layers {
|
||||
class CompositorD3D9 : public Compositor
|
||||
{
|
||||
public:
|
||||
CompositorD3D9(CompositorParent* aParent, nsIWidget *aWidget);
|
||||
CompositorD3D9(CompositorBridgeParent* aParent, nsIWidget *aWidget);
|
||||
~CompositorD3D9();
|
||||
|
||||
virtual bool Initialize() override;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "CompositableTransactionParent.h"
|
||||
#include "CompositableHost.h" // for CompositableParent, etc
|
||||
#include "CompositorParent.h" // for CompositorParent
|
||||
#include "CompositorBridgeParent.h" // for CompositorBridgeParent
|
||||
#include "GLContext.h" // for GLContext
|
||||
#include "Layers.h" // for Layer
|
||||
#include "RenderTrace.h" // for RenderTraceInvalidateEnd, etc
|
||||
@@ -60,7 +60,7 @@ bool ScheduleComposition(const T& op)
|
||||
if (!comp || !id) {
|
||||
return false;
|
||||
}
|
||||
CompositorParent* cp = CompositorParent::GetCompositor(id);
|
||||
CompositorBridgeParent* cp = CompositorBridgeParent::GetCompositor(id);
|
||||
if (!cp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* 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 "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include <stddef.h> // for size_t
|
||||
#include "ClientLayerManager.h" // for ClientLayerManager
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
@@ -34,36 +34,36 @@ using mozilla::Unused;
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/*static*/ CompositorChild* CompositorChild::sCompositor;
|
||||
/*static*/ CompositorBridgeChild* CompositorBridgeChild::sCompositor;
|
||||
|
||||
Atomic<int32_t> CompositableForwarder::sSerialCounter(0);
|
||||
|
||||
CompositorChild::CompositorChild(ClientLayerManager *aLayerManager)
|
||||
CompositorBridgeChild::CompositorBridgeChild(ClientLayerManager *aLayerManager)
|
||||
: mLayerManager(aLayerManager)
|
||||
, mCanSend(false)
|
||||
{
|
||||
}
|
||||
|
||||
CompositorChild::~CompositorChild()
|
||||
CompositorBridgeChild::~CompositorBridgeChild()
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
|
||||
new DeleteTask<Transport>(GetTransport()));
|
||||
|
||||
if (mCanSend) {
|
||||
gfxCriticalError() << "CompositorChild was not deinitialized";
|
||||
gfxCriticalError() << "CompositorBridgeChild was not deinitialized";
|
||||
}
|
||||
}
|
||||
|
||||
static void DeferredDestroyCompositor(RefPtr<CompositorParent> aCompositorParent,
|
||||
RefPtr<CompositorChild> aCompositorChild)
|
||||
static void DeferredDestroyCompositor(RefPtr<CompositorBridgeParent> aCompositorBridgeParent,
|
||||
RefPtr<CompositorBridgeChild> aCompositorBridgeChild)
|
||||
{
|
||||
// Bug 848949 needs to be fixed before
|
||||
// we can close the channel properly
|
||||
//aCompositorChild->Close();
|
||||
//aCompositorBridgeChild->Close();
|
||||
}
|
||||
|
||||
void
|
||||
CompositorChild::Destroy()
|
||||
CompositorBridgeChild::Destroy()
|
||||
{
|
||||
// This must not be called from the destructor!
|
||||
MOZ_ASSERT(mRefCnt != 0);
|
||||
@@ -77,15 +77,15 @@ CompositorChild::Destroy()
|
||||
// Destroying the layer manager may cause all sorts of things to happen, so
|
||||
// let's make sure there is still a reference to keep this alive whatever
|
||||
// happens.
|
||||
RefPtr<CompositorChild> selfRef = this;
|
||||
RefPtr<CompositorBridgeChild> selfRef = this;
|
||||
|
||||
SendWillStop();
|
||||
// The call just made to SendWillStop can result in IPC from the
|
||||
// CompositorParent to the CompositorChild (e.g. caused by the destruction
|
||||
// CompositorBridgeParent to the CompositorBridgeChild (e.g. caused by the destruction
|
||||
// of shared memory). We need to ensure this gets processed by the
|
||||
// CompositorChild before it gets destroyed. It suffices to ensure that
|
||||
// CompositorBridgeChild before it gets destroyed. It suffices to ensure that
|
||||
// events already in the MessageLoop get processed before the
|
||||
// CompositorChild is destroyed, so we add a task to the MessageLoop to
|
||||
// CompositorBridgeChild is destroyed, so we add a task to the MessageLoop to
|
||||
// handle compositor desctruction.
|
||||
|
||||
// From now on the only message we can send is Stop.
|
||||
@@ -108,12 +108,12 @@ CompositorChild::Destroy()
|
||||
// The DeferredDestroyCompositor task takes ownership of compositorParent and
|
||||
// will release them when it runs.
|
||||
MessageLoop::current()->PostTask(FROM_HERE,
|
||||
NewRunnableFunction(DeferredDestroyCompositor, mCompositorParent, selfRef));
|
||||
NewRunnableFunction(DeferredDestroyCompositor, mCompositorBridgeParent, selfRef));
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::LookupCompositorFrameMetrics(const FrameMetrics::ViewID aId,
|
||||
FrameMetrics& aFrame)
|
||||
CompositorBridgeChild::LookupCompositorFrameMetrics(const FrameMetrics::ViewID aId,
|
||||
FrameMetrics& aFrame)
|
||||
{
|
||||
SharedFrameMetricsData* data = mFrameMetricsTable.Get(aId);
|
||||
if (data) {
|
||||
@@ -124,12 +124,12 @@ CompositorChild::LookupCompositorFrameMetrics(const FrameMetrics::ViewID aId,
|
||||
}
|
||||
|
||||
/*static*/ PCompositorBridgeChild*
|
||||
CompositorChild::Create(Transport* aTransport, ProcessId aOtherPid)
|
||||
CompositorBridgeChild::Create(Transport* aTransport, ProcessId aOtherPid)
|
||||
{
|
||||
// There's only one compositor per child process.
|
||||
MOZ_ASSERT(!sCompositor);
|
||||
|
||||
RefPtr<CompositorChild> child(new CompositorChild(nullptr));
|
||||
RefPtr<CompositorBridgeChild> child(new CompositorBridgeChild(nullptr));
|
||||
if (!child->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop(), ipc::ChildSide)) {
|
||||
NS_RUNTIMEABORT("Couldn't Open() Compositor channel.");
|
||||
return nullptr;
|
||||
@@ -150,19 +150,19 @@ CompositorChild::Create(Transport* aTransport, ProcessId aOtherPid)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::OpenSameProcess(CompositorParent* aParent)
|
||||
CompositorBridgeChild::OpenSameProcess(CompositorBridgeParent* aParent)
|
||||
{
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
mCompositorParent = aParent;
|
||||
mCanSend = Open(mCompositorParent->GetIPCChannel(),
|
||||
CompositorParent::CompositorLoop(),
|
||||
mCompositorBridgeParent = aParent;
|
||||
mCanSend = Open(mCompositorBridgeParent->GetIPCChannel(),
|
||||
CompositorBridgeParent::CompositorLoop(),
|
||||
ipc::ChildSide);
|
||||
return mCanSend;
|
||||
}
|
||||
|
||||
/*static*/ CompositorChild*
|
||||
CompositorChild::Get()
|
||||
/*static*/ CompositorBridgeChild*
|
||||
CompositorBridgeChild::Get()
|
||||
{
|
||||
// This is only expected to be used in child processes.
|
||||
MOZ_ASSERT(!XRE_IsParentProcess());
|
||||
@@ -170,10 +170,10 @@ CompositorChild::Get()
|
||||
}
|
||||
|
||||
PLayerTransactionChild*
|
||||
CompositorChild::AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
|
||||
const uint64_t& aId,
|
||||
TextureFactoryIdentifier*,
|
||||
bool*)
|
||||
CompositorBridgeChild::AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
|
||||
const uint64_t& aId,
|
||||
TextureFactoryIdentifier*,
|
||||
bool*)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
LayerTransactionChild* c = new LayerTransactionChild(aId);
|
||||
@@ -182,7 +182,7 @@ CompositorChild::AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBac
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::DeallocPLayerTransactionChild(PLayerTransactionChild* actor)
|
||||
CompositorBridgeChild::DeallocPLayerTransactionChild(PLayerTransactionChild* actor)
|
||||
{
|
||||
uint64_t childId = static_cast<LayerTransactionChild*>(actor)->GetId();
|
||||
|
||||
@@ -197,7 +197,7 @@ CompositorChild::DeallocPLayerTransactionChild(PLayerTransactionChild* actor)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::RecvInvalidateLayers(const uint64_t& aLayersId)
|
||||
CompositorBridgeChild::RecvInvalidateLayers(const uint64_t& aLayersId)
|
||||
{
|
||||
if (mLayerManager) {
|
||||
MOZ_ASSERT(aLayersId == 0);
|
||||
@@ -211,7 +211,7 @@ CompositorChild::RecvInvalidateLayers(const uint64_t& aLayersId)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::RecvCompositorUpdated(const uint64_t& aLayersId,
|
||||
CompositorBridgeChild::RecvCompositorUpdated(const uint64_t& aLayersId,
|
||||
const TextureFactoryIdentifier& aNewIdentifier)
|
||||
{
|
||||
if (mLayerManager) {
|
||||
@@ -263,12 +263,12 @@ static void CalculatePluginClip(const LayoutDeviceIntRect& aBounds,
|
||||
#endif
|
||||
|
||||
bool
|
||||
CompositorChild::RecvUpdatePluginConfigurations(const LayoutDeviceIntPoint& aContentOffset,
|
||||
const LayoutDeviceIntRegion& aParentLayerVisibleRegion,
|
||||
nsTArray<PluginWindowData>&& aPlugins)
|
||||
CompositorBridgeChild::RecvUpdatePluginConfigurations(const LayoutDeviceIntPoint& aContentOffset,
|
||||
const LayoutDeviceIntRegion& aParentLayerVisibleRegion,
|
||||
nsTArray<PluginWindowData>&& aPlugins)
|
||||
{
|
||||
#if !defined(XP_WIN) && !defined(MOZ_WIDGET_GTK)
|
||||
NS_NOTREACHED("CompositorChild::RecvUpdatePluginConfigurations calls "
|
||||
NS_NOTREACHED("CompositorBridgeChild::RecvUpdatePluginConfigurations calls "
|
||||
"unexpected on this platform.");
|
||||
return false;
|
||||
#else
|
||||
@@ -351,10 +351,10 @@ CompositorChild::RecvUpdatePluginConfigurations(const LayoutDeviceIntPoint& aCon
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::RecvHideAllPlugins(const uintptr_t& aParentWidget)
|
||||
CompositorBridgeChild::RecvHideAllPlugins(const uintptr_t& aParentWidget)
|
||||
{
|
||||
#if !defined(XP_WIN) && !defined(MOZ_WIDGET_GTK)
|
||||
NS_NOTREACHED("CompositorChild::RecvHideAllPlugins calls "
|
||||
NS_NOTREACHED("CompositorBridgeChild::RecvHideAllPlugins calls "
|
||||
"unexpected on this platform.");
|
||||
return false;
|
||||
#else
|
||||
@@ -369,9 +369,9 @@ CompositorChild::RecvHideAllPlugins(const uintptr_t& aParentWidget)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId,
|
||||
const TimeStamp& aCompositeStart,
|
||||
const TimeStamp& aCompositeEnd)
|
||||
CompositorBridgeChild::RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId,
|
||||
const TimeStamp& aCompositeStart,
|
||||
const TimeStamp& aCompositeEnd)
|
||||
{
|
||||
if (mLayerManager) {
|
||||
MOZ_ASSERT(aId == 0);
|
||||
@@ -387,7 +387,7 @@ CompositorChild::RecvDidComposite(const uint64_t& aId, const uint64_t& aTransact
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::RecvOverfill(const uint32_t &aOverfill)
|
||||
CompositorBridgeChild::RecvOverfill(const uint32_t &aOverfill)
|
||||
{
|
||||
for (size_t i = 0; i < mOverfillObservers.Length(); i++) {
|
||||
mOverfillObservers[i]->RunOverfillCallback(aOverfill);
|
||||
@@ -397,14 +397,14 @@ CompositorChild::RecvOverfill(const uint32_t &aOverfill)
|
||||
}
|
||||
|
||||
void
|
||||
CompositorChild::AddOverfillObserver(ClientLayerManager* aLayerManager)
|
||||
CompositorBridgeChild::AddOverfillObserver(ClientLayerManager* aLayerManager)
|
||||
{
|
||||
MOZ_ASSERT(aLayerManager);
|
||||
mOverfillObservers.AppendElement(aLayerManager);
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::RecvClearCachedResources(const uint64_t& aId)
|
||||
CompositorBridgeChild::RecvClearCachedResources(const uint64_t& aId)
|
||||
{
|
||||
dom::TabChild* child = dom::TabChild::GetFrom(aId);
|
||||
if (child) {
|
||||
@@ -414,28 +414,32 @@ CompositorChild::RecvClearCachedResources(const uint64_t& aId)
|
||||
}
|
||||
|
||||
void
|
||||
CompositorChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
CompositorBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
MOZ_ASSERT(!mCanSend);
|
||||
MOZ_ASSERT(sCompositor == this);
|
||||
|
||||
if (aWhy == AbnormalShutdown) {
|
||||
#ifdef MOZ_B2G
|
||||
// Due to poor lifetime management of gralloc (and possibly shmems) we will
|
||||
// crash at some point in the future when we get destroyed due to abnormal
|
||||
// shutdown. Its better just to crash here. On desktop though, we have a chance
|
||||
// of recovering.
|
||||
if (aWhy == AbnormalShutdown) {
|
||||
NS_RUNTIMEABORT("ActorDestroy by IPC channel failure at CompositorChild");
|
||||
}
|
||||
NS_RUNTIMEABORT("ActorDestroy by IPC channel failure at CompositorBridgeChild");
|
||||
#endif
|
||||
|
||||
// If the parent side runs into a problem then the actor will be destroyed.
|
||||
// There is nothing we can do in the child side, here sets mCanSend as false.
|
||||
mCanSend = false;
|
||||
gfxCriticalNote << "Receive IPC close with reason=" << aWhy;
|
||||
}
|
||||
|
||||
MessageLoop::current()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(this, &CompositorChild::Release));
|
||||
NewRunnableMethod(this, &CompositorBridgeChild::Release));
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::RecvSharedCompositorFrameMetrics(
|
||||
CompositorBridgeChild::RecvSharedCompositorFrameMetrics(
|
||||
const mozilla::ipc::SharedMemoryBasic::Handle& metrics,
|
||||
const CrossProcessMutexHandle& handle,
|
||||
const uint64_t& aLayersId,
|
||||
@@ -448,7 +452,7 @@ CompositorChild::RecvSharedCompositorFrameMetrics(
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::RecvReleaseSharedCompositorFrameMetrics(
|
||||
CompositorBridgeChild::RecvReleaseSharedCompositorFrameMetrics(
|
||||
const ViewID& aId,
|
||||
const uint32_t& aAPZCId)
|
||||
{
|
||||
@@ -462,7 +466,7 @@ CompositorChild::RecvReleaseSharedCompositorFrameMetrics(
|
||||
return true;
|
||||
}
|
||||
|
||||
CompositorChild::SharedFrameMetricsData::SharedFrameMetricsData(
|
||||
CompositorBridgeChild::SharedFrameMetricsData::SharedFrameMetricsData(
|
||||
const ipc::SharedMemoryBasic::Handle& metrics,
|
||||
const CrossProcessMutexHandle& handle,
|
||||
const uint64_t& aLayersId,
|
||||
@@ -478,7 +482,7 @@ CompositorChild::SharedFrameMetricsData::SharedFrameMetricsData(
|
||||
MOZ_COUNT_CTOR(SharedFrameMetricsData);
|
||||
}
|
||||
|
||||
CompositorChild::SharedFrameMetricsData::~SharedFrameMetricsData()
|
||||
CompositorBridgeChild::SharedFrameMetricsData::~SharedFrameMetricsData()
|
||||
{
|
||||
// When the hash table deletes the class, delete
|
||||
// the shared memory and mutex.
|
||||
@@ -488,7 +492,7 @@ CompositorChild::SharedFrameMetricsData::~SharedFrameMetricsData()
|
||||
}
|
||||
|
||||
void
|
||||
CompositorChild::SharedFrameMetricsData::CopyFrameMetrics(FrameMetrics* aFrame)
|
||||
CompositorBridgeChild::SharedFrameMetricsData::CopyFrameMetrics(FrameMetrics* aFrame)
|
||||
{
|
||||
FrameMetrics* frame = static_cast<FrameMetrics*>(mBuffer->memory());
|
||||
MOZ_ASSERT(frame);
|
||||
@@ -498,7 +502,7 @@ CompositorChild::SharedFrameMetricsData::CopyFrameMetrics(FrameMetrics* aFrame)
|
||||
}
|
||||
|
||||
FrameMetrics::ViewID
|
||||
CompositorChild::SharedFrameMetricsData::GetViewID()
|
||||
CompositorBridgeChild::SharedFrameMetricsData::GetViewID()
|
||||
{
|
||||
FrameMetrics* frame = static_cast<FrameMetrics*>(mBuffer->memory());
|
||||
MOZ_ASSERT(frame);
|
||||
@@ -508,26 +512,26 @@ CompositorChild::SharedFrameMetricsData::GetViewID()
|
||||
}
|
||||
|
||||
uint64_t
|
||||
CompositorChild::SharedFrameMetricsData::GetLayersId() const
|
||||
CompositorBridgeChild::SharedFrameMetricsData::GetLayersId() const
|
||||
{
|
||||
return mLayersId;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
CompositorChild::SharedFrameMetricsData::GetAPZCId()
|
||||
CompositorBridgeChild::SharedFrameMetricsData::GetAPZCId()
|
||||
{
|
||||
return mAPZCId;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CompositorChild::RecvRemotePaintIsReady()
|
||||
CompositorBridgeChild::RecvRemotePaintIsReady()
|
||||
{
|
||||
// Used on the content thread, this bounces the message to the
|
||||
// TabParent (via the TabChild) if the notification was previously requested.
|
||||
// XPCOM gives a soup of compiler errors when trying to do_QueryReference
|
||||
// so I'm using static_cast<>
|
||||
MOZ_LAYERS_LOG(("[RemoteGfx] CompositorChild received RemotePaintIsReady"));
|
||||
MOZ_LAYERS_LOG(("[RemoteGfx] CompositorBridgeChild received RemotePaintIsReady"));
|
||||
RefPtr<nsISupports> iTabChildBase(do_QueryReferent(mWeakTabChild));
|
||||
if (!iTabChildBase) {
|
||||
MOZ_LAYERS_LOG(("[RemoteGfx] Note: TabChild was released before RemotePaintIsReady. "
|
||||
@@ -544,15 +548,15 @@ CompositorChild::RecvRemotePaintIsReady()
|
||||
|
||||
|
||||
void
|
||||
CompositorChild::RequestNotifyAfterRemotePaint(TabChild* aTabChild)
|
||||
CompositorBridgeChild::RequestNotifyAfterRemotePaint(TabChild* aTabChild)
|
||||
{
|
||||
MOZ_ASSERT(aTabChild, "NULL TabChild not allowed in CompositorChild::RequestNotifyAfterRemotePaint");
|
||||
MOZ_ASSERT(aTabChild, "NULL TabChild not allowed in CompositorBridgeChild::RequestNotifyAfterRemotePaint");
|
||||
mWeakTabChild = do_GetWeakReference( static_cast<dom::TabChildBase*>(aTabChild) );
|
||||
Unused << SendRequestNotifyAfterRemotePaint();
|
||||
}
|
||||
|
||||
void
|
||||
CompositorChild::CancelNotifyAfterRemotePaint(TabChild* aTabChild)
|
||||
CompositorBridgeChild::CancelNotifyAfterRemotePaint(TabChild* aTabChild)
|
||||
{
|
||||
RefPtr<nsISupports> iTabChildBase(do_QueryReferent(mWeakTabChild));
|
||||
if (!iTabChildBase) {
|
||||
@@ -566,13 +570,13 @@ CompositorChild::CancelNotifyAfterRemotePaint(TabChild* aTabChild)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendWillStop()
|
||||
CompositorBridgeChild::SendWillStop()
|
||||
{
|
||||
return PCompositorBridgeChild::SendWillStop();
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendPause()
|
||||
CompositorBridgeChild::SendPause()
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -582,7 +586,7 @@ CompositorChild::SendPause()
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendResume()
|
||||
CompositorBridgeChild::SendResume()
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -592,7 +596,7 @@ CompositorChild::SendResume()
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendNotifyHidden(const uint64_t& id)
|
||||
CompositorBridgeChild::SendNotifyHidden(const uint64_t& id)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -602,7 +606,7 @@ CompositorChild::SendNotifyHidden(const uint64_t& id)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendNotifyVisible(const uint64_t& id)
|
||||
CompositorBridgeChild::SendNotifyVisible(const uint64_t& id)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -612,7 +616,7 @@ CompositorChild::SendNotifyVisible(const uint64_t& id)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendNotifyChildCreated(const uint64_t& id)
|
||||
CompositorBridgeChild::SendNotifyChildCreated(const uint64_t& id)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -622,7 +626,7 @@ CompositorChild::SendNotifyChildCreated(const uint64_t& id)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendAdoptChild(const uint64_t& id)
|
||||
CompositorBridgeChild::SendAdoptChild(const uint64_t& id)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -632,7 +636,7 @@ CompositorChild::SendAdoptChild(const uint64_t& id)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendMakeSnapshot(const SurfaceDescriptor& inSnapshot, const gfx::IntRect& dirtyRect)
|
||||
CompositorBridgeChild::SendMakeSnapshot(const SurfaceDescriptor& inSnapshot, const gfx::IntRect& dirtyRect)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -642,7 +646,7 @@ CompositorChild::SendMakeSnapshot(const SurfaceDescriptor& inSnapshot, const gfx
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendFlushRendering()
|
||||
CompositorBridgeChild::SendFlushRendering()
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -652,7 +656,7 @@ CompositorChild::SendFlushRendering()
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendGetTileSize(int32_t* tileWidth, int32_t* tileHeight)
|
||||
CompositorBridgeChild::SendGetTileSize(int32_t* tileWidth, int32_t* tileHeight)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -662,7 +666,7 @@ CompositorChild::SendGetTileSize(int32_t* tileWidth, int32_t* tileHeight)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendStartFrameTimeRecording(const int32_t& bufferSize, uint32_t* startIndex)
|
||||
CompositorBridgeChild::SendStartFrameTimeRecording(const int32_t& bufferSize, uint32_t* startIndex)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -672,7 +676,7 @@ CompositorChild::SendStartFrameTimeRecording(const int32_t& bufferSize, uint32_t
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendStopFrameTimeRecording(const uint32_t& startIndex, nsTArray<float>* intervals)
|
||||
CompositorBridgeChild::SendStopFrameTimeRecording(const uint32_t& startIndex, nsTArray<float>* intervals)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -682,7 +686,7 @@ CompositorChild::SendStopFrameTimeRecording(const uint32_t& startIndex, nsTArray
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendNotifyRegionInvalidated(const nsIntRegion& region)
|
||||
CompositorBridgeChild::SendNotifyRegionInvalidated(const nsIntRegion& region)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -692,7 +696,7 @@ CompositorChild::SendNotifyRegionInvalidated(const nsIntRegion& region)
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendRequestNotifyAfterRemotePaint()
|
||||
CompositorBridgeChild::SendRequestNotifyAfterRemotePaint()
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -702,8 +706,8 @@ CompositorChild::SendRequestNotifyAfterRemotePaint()
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendClearApproximatelyVisibleRegions(uint64_t aLayersId,
|
||||
uint32_t aPresShellId)
|
||||
CompositorBridgeChild::SendClearApproximatelyVisibleRegions(uint64_t aLayersId,
|
||||
uint32_t aPresShellId)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -714,8 +718,8 @@ CompositorChild::SendClearApproximatelyVisibleRegions(uint64_t aLayersId,
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::SendNotifyApproximatelyVisibleRegion(const ScrollableLayerGuid& aGuid,
|
||||
const CSSIntRegion& aRegion)
|
||||
CompositorBridgeChild::SendNotifyApproximatelyVisibleRegion(const ScrollableLayerGuid& aGuid,
|
||||
const CSSIntRegion& aRegion)
|
||||
{
|
||||
MOZ_ASSERT(mCanSend);
|
||||
if (!mCanSend) {
|
||||
@@ -4,8 +4,8 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef mozilla_layers_CompositorChild_h
|
||||
#define mozilla_layers_CompositorChild_h
|
||||
#ifndef mozilla_layers_CompositorBridgeChild_h
|
||||
#define mozilla_layers_CompositorBridgeChild_h
|
||||
|
||||
#include "base/basictypes.h" // for DISALLOW_EVIL_CONSTRUCTORS
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
||||
@@ -31,15 +31,15 @@ namespace layers {
|
||||
using mozilla::dom::TabChild;
|
||||
|
||||
class ClientLayerManager;
|
||||
class CompositorParent;
|
||||
class CompositorBridgeParent;
|
||||
struct FrameMetrics;
|
||||
|
||||
class CompositorChild final : public PCompositorBridgeChild
|
||||
class CompositorBridgeChild final : public PCompositorBridgeChild
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CompositorChild)
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CompositorBridgeChild)
|
||||
|
||||
public:
|
||||
explicit CompositorChild(ClientLayerManager *aLayerManager);
|
||||
explicit CompositorBridgeChild(ClientLayerManager *aLayerManager);
|
||||
|
||||
void Destroy();
|
||||
|
||||
@@ -59,12 +59,12 @@ public:
|
||||
Create(Transport* aTransport, ProcessId aOtherProcess);
|
||||
|
||||
/**
|
||||
* Initialize the CompositorChild and open the connection in the non-multi-process
|
||||
* Initialize the CompositorBridgeChild and open the connection in the non-multi-process
|
||||
* case.
|
||||
*/
|
||||
bool OpenSameProcess(CompositorParent* aParent);
|
||||
bool OpenSameProcess(CompositorBridgeParent* aParent);
|
||||
|
||||
static CompositorChild* Get();
|
||||
static CompositorBridgeChild* Get();
|
||||
|
||||
static bool ChildProcessHasCompositor() { return sCompositor != nullptr; }
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
|
||||
private:
|
||||
// Private destructor, to discourage deletion outside of Release():
|
||||
virtual ~CompositorChild();
|
||||
virtual ~CompositorBridgeChild();
|
||||
|
||||
virtual PLayerTransactionChild*
|
||||
AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
|
||||
@@ -182,9 +182,9 @@ private:
|
||||
};
|
||||
|
||||
RefPtr<ClientLayerManager> mLayerManager;
|
||||
// When not multi-process, hold a reference to the CompositorParent to keep it
|
||||
// When not multi-process, hold a reference to the CompositorBridgeParent to keep it
|
||||
// alive. This reference should be null in multi-process.
|
||||
RefPtr<CompositorParent> mCompositorParent;
|
||||
RefPtr<CompositorBridgeParent> mCompositorBridgeParent;
|
||||
|
||||
// The ViewID of the FrameMetrics is used as the key for this hash table.
|
||||
// While this should be safe to use since the ViewID is unique
|
||||
@@ -193,13 +193,13 @@ private:
|
||||
// When we're in a child process, this is the process-global
|
||||
// compositor that we use to forward transactions directly to the
|
||||
// compositor context in another process.
|
||||
static CompositorChild* sCompositor;
|
||||
static CompositorBridgeChild* sCompositor;
|
||||
|
||||
// Weakly hold the TabChild that made a request to be alerted when
|
||||
// the transaction has been received.
|
||||
nsWeakPtr mWeakTabChild; // type is TabChild
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CompositorChild);
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CompositorBridgeChild);
|
||||
|
||||
// When we receive overfill numbers, notify these client layer managers
|
||||
AutoTArray<ClientLayerManager*,0> mOverfillObservers;
|
||||
@@ -211,4 +211,4 @@ private:
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_layers_CompositorChild_h
|
||||
#endif // mozilla_layers_CompositorBrigedChild_h
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,8 +4,8 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef mozilla_layers_CompositorParent_h
|
||||
#define mozilla_layers_CompositorParent_h
|
||||
#ifndef mozilla_layers_CompositorBridgeParent_h
|
||||
#define mozilla_layers_CompositorBridgeParent_h
|
||||
|
||||
// Enable this pref to turn on compositor performance warning.
|
||||
// This will print warnings if the compositor isn't meeting
|
||||
@@ -53,11 +53,11 @@ namespace layers {
|
||||
class APZCTreeManager;
|
||||
class AsyncCompositionManager;
|
||||
class Compositor;
|
||||
class CompositorParent;
|
||||
class CompositorBridgeParent;
|
||||
class LayerManagerComposite;
|
||||
class LayerTransactionParent;
|
||||
class PAPZParent;
|
||||
class CrossProcessCompositorParent;
|
||||
class CrossProcessCompositorBridgeParent;
|
||||
|
||||
struct ScopedLayerTreeRegistration
|
||||
{
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
static base::Thread* CreateCompositorThread();
|
||||
static void DestroyCompositorThread(base::Thread* aCompositorThread);
|
||||
|
||||
friend class CompositorParent;
|
||||
friend class CompositorBridgeParent;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ class CompositorVsyncScheduler
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorVsyncScheduler)
|
||||
|
||||
public:
|
||||
explicit CompositorVsyncScheduler(CompositorParent* aCompositorParent, nsIWidget* aWidget);
|
||||
explicit CompositorVsyncScheduler(CompositorBridgeParent* aCompositorBridgeParent, nsIWidget* aWidget);
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// emulator-ics never trigger the display on/off, so compositor will always
|
||||
@@ -174,7 +174,7 @@ private:
|
||||
CompositorVsyncScheduler* mOwner;
|
||||
};
|
||||
|
||||
CompositorParent* mCompositorParent;
|
||||
CompositorBridgeParent* mCompositorBridgeParent;
|
||||
TimeStamp mLastCompose;
|
||||
|
||||
#ifdef COMPOSITOR_PERFORMANCE_WARNING
|
||||
@@ -214,14 +214,14 @@ protected:
|
||||
virtual ~CompositorUpdateObserver() {}
|
||||
};
|
||||
|
||||
class CompositorParent final : public PCompositorBridgeParent,
|
||||
class CompositorBridgeParent final : public PCompositorBridgeParent,
|
||||
public ShadowLayersManager
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CompositorParent)
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CompositorBridgeParent)
|
||||
friend class CompositorVsyncScheduler;
|
||||
|
||||
public:
|
||||
explicit CompositorParent(nsIWidget* aWidget,
|
||||
explicit CompositorBridgeParent(nsIWidget* aWidget,
|
||||
bool aUseExternalSurfaceSize = false,
|
||||
int aSurfaceWidth = -1, int aSurfaceHeight = -1);
|
||||
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
virtual bool RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray<float>* intervals) override;
|
||||
|
||||
// Unused for chrome <-> compositor communication (which this class does).
|
||||
// @see CrossProcessCompositorParent::RecvRequestNotifyAfterRemotePaint
|
||||
// @see CrossProcessCompositorBridgeParent::RecvRequestNotifyAfterRemotePaint
|
||||
virtual bool RecvRequestNotifyAfterRemotePaint() override { return true; };
|
||||
|
||||
virtual bool RecvClearApproximatelyVisibleRegions(const uint64_t& aLayersId,
|
||||
@@ -353,12 +353,12 @@ public:
|
||||
/**
|
||||
* Returns a pointer to the compositor corresponding to the given ID.
|
||||
*/
|
||||
static CompositorParent* GetCompositor(uint64_t id);
|
||||
static CompositorBridgeParent* GetCompositor(uint64_t id);
|
||||
|
||||
/**
|
||||
* Returns the compositor thread's message loop.
|
||||
*
|
||||
* This message loop is used by CompositorParent, ImageBridgeParent,
|
||||
* This message loop is used by CompositorBridgeParent, ImageBridgeParent,
|
||||
* and VRManagerParent
|
||||
*/
|
||||
static MessageLoop* CompositorLoop();
|
||||
@@ -369,7 +369,7 @@ public:
|
||||
static void StartUp();
|
||||
|
||||
/**
|
||||
* Waits for all [CrossProcess]CompositorParent's to be gone,
|
||||
* Waits for all [CrossProcess]CompositorBridgeParent's to be gone,
|
||||
* and destroys the compositor thread and global compositor map.
|
||||
*
|
||||
* Does not return until all of that has completed.
|
||||
@@ -417,12 +417,12 @@ public:
|
||||
~LayerTreeState();
|
||||
RefPtr<Layer> mRoot;
|
||||
RefPtr<GeckoContentController> mController;
|
||||
CompositorParent* mParent;
|
||||
CompositorBridgeParent* mParent;
|
||||
LayerManagerComposite* mLayerManager;
|
||||
// Pointer to the CrossProcessCompositorParent. Used by APZCs to share
|
||||
// Pointer to the CrossProcessCompositorBridgeParent. Used by APZCs to share
|
||||
// their FrameMetrics with the corresponding child process that holds
|
||||
// the PCompositorBridgeChild
|
||||
CrossProcessCompositorParent* mCrossProcessParent;
|
||||
CrossProcessCompositorBridgeParent* mCrossProcessParent;
|
||||
TargetConfig mTargetConfig;
|
||||
APZTestData mApzTestData;
|
||||
LayerTransactionParent* mLayerTree;
|
||||
@@ -500,7 +500,7 @@ public:
|
||||
|
||||
protected:
|
||||
// Protected destructor, to discourage deletion outside of Release():
|
||||
virtual ~CompositorParent();
|
||||
virtual ~CompositorBridgeParent();
|
||||
|
||||
void DeferredDestroy();
|
||||
|
||||
@@ -531,11 +531,11 @@ protected:
|
||||
/**
|
||||
* Add a compositor to the global compositor map.
|
||||
*/
|
||||
static void AddCompositor(CompositorParent* compositor, uint64_t* id);
|
||||
static void AddCompositor(CompositorBridgeParent* compositor, uint64_t* id);
|
||||
/**
|
||||
* Remove a compositor from the global compositor map.
|
||||
*/
|
||||
static CompositorParent* RemoveCompositor(uint64_t id);
|
||||
static CompositorBridgeParent* RemoveCompositor(uint64_t id);
|
||||
|
||||
/**
|
||||
* Return true if current state allows compositing, that is
|
||||
@@ -596,10 +596,10 @@ protected:
|
||||
bool mPluginWindowsHidden;
|
||||
#endif
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CompositorBridgeParent);
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_layers_CompositorParent_h
|
||||
#endif // mozilla_layers_CompositorBridgeParent_h
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "CompositorParent.h"
|
||||
#include "CompositorBridgeParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "mozilla/media/MediaSystemResourceManager.h" // for MediaSystemResourceManager
|
||||
#include "mozilla/media/MediaSystemResourceManagerChild.h" // for MediaSystemResourceManagerChild
|
||||
#include "mozilla/layers/CompositableClient.h" // for CompositableChild, etc
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent
|
||||
#include "mozilla/layers/ISurfaceAllocator.h" // for ISurfaceAllocator
|
||||
#include "mozilla/layers/ImageClient.h" // for ImageClient
|
||||
#include "mozilla/layers/LayersMessages.h" // for CompositableOperation
|
||||
@@ -771,7 +771,7 @@ bool ImageBridgeChild::StartUpOnThread(Thread* aThread)
|
||||
}
|
||||
sImageBridgeChildSingleton = new ImageBridgeChild();
|
||||
sImageBridgeParentSingleton = new ImageBridgeParent(
|
||||
CompositorParent::CompositorLoop(), nullptr, base::GetCurrentProcId());
|
||||
CompositorBridgeParent::CompositorLoop(), nullptr, base::GetCurrentProcId());
|
||||
sImageBridgeChildSingleton->ConnectAsync(sImageBridgeParentSingleton);
|
||||
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "mozilla/ipc/Transport.h" // for Transport
|
||||
#include "mozilla/media/MediaSystemResourceManagerParent.h" // for MediaSystemResourceManagerParent
|
||||
#include "mozilla/layers/CompositableTransactionParent.h"
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/LayersMessages.h" // for EditReply
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for PGrallocBufferParent
|
||||
@@ -49,7 +49,7 @@ std::map<base::ProcessId, ImageBridgeParent*> ImageBridgeParent::sImageBridges;
|
||||
|
||||
MessageLoop* ImageBridgeParent::sMainLoop = nullptr;
|
||||
|
||||
// defined in CompositorParent.cpp
|
||||
// defined in CompositorBridgeParent.cpp
|
||||
CompositorThreadHolder* GetCompositorThreadHolder();
|
||||
|
||||
ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
|
||||
@@ -184,7 +184,7 @@ ConnectImageBridgeInParentProcess(ImageBridgeParent* aBridge,
|
||||
/*static*/ PImageBridgeParent*
|
||||
ImageBridgeParent::Create(Transport* aTransport, ProcessId aChildProcessId)
|
||||
{
|
||||
MessageLoop* loop = CompositorParent::CompositorLoop();
|
||||
MessageLoop* loop = CompositorBridgeParent::CompositorLoop();
|
||||
RefPtr<ImageBridgeParent> bridge = new ImageBridgeParent(loop, aTransport, aChildProcessId);
|
||||
bridge->mSelfRef = bridge;
|
||||
loop->PostTask(FROM_HERE,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/PImageBridgeParent.h"
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
@@ -27,7 +27,7 @@ LayerTransactionChild::Destroy()
|
||||
return;
|
||||
}
|
||||
// mDestroyed is used to prevent calling Send__delete__() twice.
|
||||
// When this function is called from CompositorChild::Destroy(),
|
||||
// When this function is called from CompositorBridgeChild::Destroy(),
|
||||
// under Send__delete__() call, this function is called from
|
||||
// ShadowLayerForwarder's destructor.
|
||||
// When it happens, IPCOpen() is still true.
|
||||
|
||||
@@ -84,7 +84,7 @@ protected:
|
||||
mIPCOpen = false;
|
||||
Release();
|
||||
}
|
||||
friend class CompositorChild;
|
||||
friend class CompositorBridgeChild;
|
||||
friend class layout::RenderFrameChild;
|
||||
|
||||
ShadowLayerForwarder* mForwarder;
|
||||
|
||||
@@ -712,7 +712,7 @@ LayerTransactionParent::RecvGetAnimationTransform(PLayerParent* aParent,
|
||||
|
||||
// Make sure we apply the latest animation style or else we can end up with
|
||||
// a race between when we temporarily clear the animation transform (in
|
||||
// CompositorParent::SetShadowProperties) and when animation recalculates
|
||||
// CompositorBridgeParent::SetShadowProperties) and when animation recalculates
|
||||
// the value.
|
||||
mShadowLayersManager->ApplyAsyncProperties(this);
|
||||
|
||||
|
||||
@@ -171,8 +171,8 @@ protected:
|
||||
mIPCOpen = false;
|
||||
RELEASE_MANUALLY(this);
|
||||
}
|
||||
friend class CompositorParent;
|
||||
friend class CrossProcessCompositorParent;
|
||||
friend class CompositorBridgeParent;
|
||||
friend class CrossProcessCompositorBridgeParent;
|
||||
friend class layout::RenderFrameParent;
|
||||
|
||||
private:
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layout/RenderFrameParent.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "Units.h"
|
||||
@@ -371,12 +371,12 @@ already_AddRefed<APZCTreeManager>
|
||||
RemoteContentController::GetApzcTreeManager()
|
||||
{
|
||||
// We can't get a ref to the APZCTreeManager until after the child is
|
||||
// created and the static getter knows which CompositorParent is
|
||||
// created and the static getter knows which CompositorBridgeParent is
|
||||
// instantiated with this layers ID. That's why try to fetch it when
|
||||
// we first need it and cache the result.
|
||||
MutexAutoLock lock(mMutex);
|
||||
if (!mApzcTreeManager) {
|
||||
mApzcTreeManager = CompositorParent::GetAPZCTreeManager(mLayersId);
|
||||
mApzcTreeManager = CompositorBridgeParent::GetAPZCTreeManager(mLayersId);
|
||||
}
|
||||
RefPtr<APZCTreeManager> apzcTreeManager(mApzcTreeManager);
|
||||
return apzcTreeManager.forget();
|
||||
|
||||
@@ -155,9 +155,9 @@ EXPORTS.mozilla.layers += [
|
||||
'ipc/AsyncTransactionTracker.h',
|
||||
'ipc/CompositableForwarder.h',
|
||||
'ipc/CompositableTransactionParent.h',
|
||||
'ipc/CompositorChild.h',
|
||||
'ipc/CompositorBridgeChild.h',
|
||||
'ipc/CompositorBridgeParent.h',
|
||||
'ipc/CompositorLRU.h',
|
||||
'ipc/CompositorParent.h',
|
||||
'ipc/FenceUtils.h',
|
||||
'ipc/GonkNativeHandle.h',
|
||||
'ipc/GonkNativeHandleUtils.h',
|
||||
@@ -334,9 +334,9 @@ UNIFIED_SOURCES += [
|
||||
'ipc/AsyncTransactionTracker.cpp',
|
||||
'ipc/CompositableTransactionParent.cpp',
|
||||
'ipc/CompositorBench.cpp',
|
||||
'ipc/CompositorChild.cpp',
|
||||
'ipc/CompositorBridgeChild.cpp',
|
||||
'ipc/CompositorBridgeParent.cpp',
|
||||
'ipc/CompositorLRU.cpp',
|
||||
'ipc/CompositorParent.cpp',
|
||||
'ipc/FenceUtils.cpp',
|
||||
'ipc/ImageBridgeChild.cpp',
|
||||
'ipc/ImageBridgeParent.cpp',
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "LayerUserData.h"
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
@@ -239,7 +239,7 @@ already_AddRefed<Layer> CreateLayerTree(
|
||||
manager->SetRoot(rootLayer);
|
||||
if (rootLayer->AsLayerComposite()) {
|
||||
// Only perform this for LayerManagerComposite
|
||||
CompositorParent::SetShadowProperties(rootLayer);
|
||||
CompositorBridgeParent::SetShadowProperties(rootLayer);
|
||||
}
|
||||
}
|
||||
return rootLayer.forget();
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include <cutils/properties.h>
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "HwcComposer2D.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
#include "mozilla/layers/SharedBufferManagerChild.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h" // for GfxMemoryImageReporter
|
||||
@@ -822,7 +822,7 @@ gfxPlatform::InitLayersIPC()
|
||||
|
||||
if (XRE_IsParentProcess())
|
||||
{
|
||||
mozilla::layers::CompositorParent::StartUp();
|
||||
mozilla::layers::CompositorBridgeParent::StartUp();
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
SharedBufferManagerChild::StartUp();
|
||||
#endif
|
||||
@@ -841,15 +841,15 @@ gfxPlatform::ShutdownLayersIPC()
|
||||
|
||||
if (XRE_IsParentProcess())
|
||||
{
|
||||
// This must happen after the shutdown of media and widgets, which
|
||||
// are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification.
|
||||
gfx::VRManagerChild::ShutDown();
|
||||
layers::ImageBridgeChild::ShutDown();
|
||||
// This must happen after the shutdown of media and widgets, which
|
||||
// are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification.
|
||||
gfx::VRManagerChild::ShutDown();
|
||||
layers::ImageBridgeChild::ShutDown();
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
layers::SharedBufferManagerChild::ShutDown();
|
||||
layers::SharedBufferManagerChild::ShutDown();
|
||||
#endif
|
||||
|
||||
layers::CompositorParent::ShutDown();
|
||||
layers::CompositorBridgeParent::ShutDown();
|
||||
} else if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
gfx::VRManagerChild::ShutDown();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <CoreVideo/CoreVideo.h>
|
||||
|
||||
#include "nsCocoaFeatures.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "VsyncSource.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "gfxGDIFontList.h"
|
||||
#include "gfxGDIFont.h"
|
||||
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent::IsInCompositorThread
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent::IsInCompositorThread
|
||||
#include "DeviceManagerD3D9.h"
|
||||
#include "mozilla/layers/ReadbackManagerD3D11.h"
|
||||
|
||||
@@ -1438,7 +1438,7 @@ gfxWindowsPlatform::GetD3D9DeviceManager()
|
||||
// or we don't have a compositor thread.
|
||||
if (!mDeviceManager &&
|
||||
(!gfxPlatform::UsesOffMainThreadCompositing() ||
|
||||
CompositorParent::IsInCompositorThread())) {
|
||||
CompositorBridgeParent::IsInCompositorThread())) {
|
||||
mDeviceManager = new DeviceManagerD3D9();
|
||||
if (!mDeviceManager->Init()) {
|
||||
gfxCriticalError() << "[D3D9] Could not Initialize the DeviceManagerD3D9";
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "VRDeviceProxy.h"
|
||||
#include "VRDeviceProxyOrientationFallBack.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent
|
||||
#include "mozilla/dom/Navigator.h"
|
||||
|
||||
namespace mozilla {
|
||||
@@ -77,7 +77,7 @@ VRManagerChild::StartUpSameProcess()
|
||||
sVRManagerChildSingleton = new VRManagerChild();
|
||||
sVRManagerParentSingleton = VRManagerParent::CreateSameProcess();
|
||||
sVRManagerChildSingleton->Open(sVRManagerParentSingleton->GetIPCChannel(),
|
||||
mozilla::layers::CompositorParent::CompositorLoop(),
|
||||
mozilla::layers::CompositorBridgeParent::CompositorLoop(),
|
||||
mozilla::ipc::ChildSide);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ protected:
|
||||
virtual bool RecvUpdateDeviceInfo(nsTArray<VRDeviceUpdate>&& aDeviceUpdates) override;
|
||||
virtual bool RecvUpdateDeviceSensors(nsTArray<VRSensorUpdate>&& aDeviceSensorUpdates) override;
|
||||
|
||||
friend class layers::CompositorChild;
|
||||
friend class layers::CompositorBridgeChild;
|
||||
|
||||
private:
|
||||
|
||||
@@ -59,4 +59,4 @@ private:
|
||||
} // namespace mozilla
|
||||
} // namespace gfx
|
||||
|
||||
#endif // MOZILLA_GFX_VR_VRMANAGERCHILD_H
|
||||
#endif // MOZILLA_GFX_VR_VRMANAGERCHILD_H
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
#include "mozilla/ipc/ProtocolTypes.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h" // for IToplevelProtocol
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "VRManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
// defined in CompositorParent.cpp
|
||||
// defined in CompositorBridgeParent.cpp
|
||||
CompositorThreadHolder* GetCompositorThreadHolder();
|
||||
|
||||
} // namespace layers
|
||||
@@ -76,7 +76,7 @@ VRManagerParent::ConnectVRManagerInParentProcess(VRManagerParent* aVRManager,
|
||||
/*static*/ VRManagerParent*
|
||||
VRManagerParent::CreateCrossProcess(Transport* aTransport, ProcessId aChildProcessId)
|
||||
{
|
||||
MessageLoop* loop = mozilla::layers::CompositorParent::CompositorLoop();
|
||||
MessageLoop* loop = mozilla::layers::CompositorBridgeParent::CompositorLoop();
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(loop, aTransport, aChildProcessId);
|
||||
vmp->mSelfRef = vmp;
|
||||
loop->PostTask(FROM_HERE,
|
||||
@@ -94,7 +94,7 @@ VRManagerParent::RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager
|
||||
/*static*/ VRManagerParent*
|
||||
VRManagerParent::CreateSameProcess()
|
||||
{
|
||||
MessageLoop* loop = mozilla::layers::CompositorParent::CompositorLoop();
|
||||
MessageLoop* loop = mozilla::layers::CompositorBridgeParent::CompositorLoop();
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(loop, nullptr, base::GetCurrentProcId());
|
||||
vmp->mCompositorThreadHolder = layers::GetCompositorThreadHolder();
|
||||
vmp->mSelfRef = vmp;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef MOZILLA_GFX_VR_VRMANAGERPARENT_H
|
||||
#define MOZILLA_GFX_VR_VRMANAGERPARENT_H
|
||||
|
||||
#include "mozilla/layers/CompositorParent.h" // for CompositorThreadHolder
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorThreadHolder
|
||||
#include "mozilla/gfx/PVRManagerParent.h" // for PVRManagerParent
|
||||
#include "mozilla/ipc/ProtocolUtils.h" // for IToplevelProtocol
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
};
|
||||
|
||||
inline XPCShellEnvironment*
|
||||
Environment(Handle<JSObject*> global)
|
||||
Environment(JS::Handle<JSObject*> global)
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(global)) {
|
||||
|
||||
@@ -81,14 +81,10 @@ interface nsIXPCScriptable : nsISupports
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in jsval val);
|
||||
|
||||
// The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
|
||||
// this method does something.
|
||||
boolean getProperty(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in JSValPtr vp);
|
||||
|
||||
// The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
|
||||
// this method does something.
|
||||
boolean setProperty(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in JSValPtr vp);
|
||||
|
||||
@@ -160,7 +160,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "Layers.h"
|
||||
@@ -5712,7 +5712,7 @@ NotifyCompositorOfVisibleRegionsChange(PresShell* aPresShell,
|
||||
const uint64_t layersId = tabChild->LayersId();
|
||||
const uint32_t presShellId = aPresShell->GetPresShellId();
|
||||
|
||||
// Retrieve the CompositorChild.
|
||||
// Retrieve the CompositorBridgeChild.
|
||||
LayerManager* layerManager = aPresShell->GetLayerManager();
|
||||
if (!layerManager) {
|
||||
return;
|
||||
@@ -5723,7 +5723,7 @@ NotifyCompositorOfVisibleRegionsChange(PresShell* aPresShell,
|
||||
return;
|
||||
}
|
||||
|
||||
CompositorChild* compositorChild = clientLayerManager->GetCompositorChild();
|
||||
CompositorBridgeChild* compositorChild = clientLayerManager->GetCompositorBridgeChild();
|
||||
if (!compositorChild) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/LayerTransactionParent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsFocusManager.h"
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "nsViewportFrame.h"
|
||||
#include "RenderFrameParent.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "ClientLayerManager.h"
|
||||
#include "FrameLayerBuilder.h"
|
||||
|
||||
@@ -124,7 +124,7 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
||||
} else if (XRE_IsContentProcess()) {
|
||||
ContentChild::GetSingleton()->SendAllocateLayerTreeId(browser->Manager()->ChildID(), browser->GetTabId(), aId);
|
||||
mLayersId = *aId;
|
||||
CompositorChild::Get()->SendNotifyChildCreated(mLayersId);
|
||||
CompositorBridgeChild::Get()->SendNotifyChildCreated(mLayersId);
|
||||
}
|
||||
*aSuccess = true;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ RenderFrameParent::ActorDestroy(ActorDestroyReason why)
|
||||
if (XRE_IsContentProcess()) {
|
||||
ContentChild::GetSingleton()->SendDeallocateLayerTreeId(mLayersId);
|
||||
} else {
|
||||
CompositorParent::DeallocateLayerTreeId(mLayersId);
|
||||
CompositorBridgeParent::DeallocateLayerTreeId(mLayersId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,587 +0,0 @@
|
||||
/* $NetBSD: nameser.h,v 1.19 2005/12/26 19:01:47 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Id: nameser.h,v 1.2.2.4.4.1 2004/03/09 08:33:30 marka Exp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#ifndef _ARPA_NAMESER_H_
|
||||
#define _ARPA_NAMESER_H_
|
||||
|
||||
#define BIND_4_COMPAT
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/*
|
||||
* Revision information. This is the release date in YYYYMMDD format.
|
||||
* It can change every day so the right thing to do with it is use it
|
||||
* in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not
|
||||
* compare for equality; rather, use it to determine whether your libbind.a
|
||||
* contains a new enough lib/nameser/ to support the feature you need.
|
||||
*/
|
||||
|
||||
#define __NAMESER 19991006 /* New interface version stamp. */
|
||||
|
||||
/*
|
||||
* Define constants based on RFC 883, RFC 1034, RFC 1035
|
||||
*/
|
||||
#define NS_PACKETSZ 512 /* default UDP packet size */
|
||||
#define NS_MAXDNAME 1025 /* maximum domain name */
|
||||
#define NS_MAXMSG 65535 /* maximum message size */
|
||||
#define NS_MAXCDNAME 255 /* maximum compressed domain name */
|
||||
#define NS_MAXLABEL 63 /* maximum length of domain label */
|
||||
#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
|
||||
#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
|
||||
#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
|
||||
#define NS_INT32SZ 4 /* #/bytes of data in a uint32_t */
|
||||
#define NS_INT16SZ 2 /* #/bytes of data in a uint16_t */
|
||||
#define NS_INT8SZ 1 /* #/bytes of data in a uint8_t */
|
||||
#define NS_INADDRSZ 4 /* IPv4 T_A */
|
||||
#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
|
||||
#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
|
||||
#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */
|
||||
|
||||
/*
|
||||
* These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
|
||||
* in synch with it.
|
||||
*/
|
||||
typedef enum __ns_sect {
|
||||
ns_s_qd = 0, /* Query: Question. */
|
||||
ns_s_zn = 0, /* Update: Zone. */
|
||||
ns_s_an = 1, /* Query: Answer. */
|
||||
ns_s_pr = 1, /* Update: Prerequisites. */
|
||||
ns_s_ns = 2, /* Query: Name servers. */
|
||||
ns_s_ud = 2, /* Update: Update. */
|
||||
ns_s_ar = 3, /* Query|Update: Additional records. */
|
||||
ns_s_max = 4
|
||||
} ns_sect;
|
||||
|
||||
/*
|
||||
* This is a message handle. It is caller allocated and has no dynamic data.
|
||||
* This structure is intended to be opaque to all but ns_parse.c, thus the
|
||||
* leading _'s on the member names. Use the accessor functions, not the _'s.
|
||||
*/
|
||||
typedef struct __ns_msg {
|
||||
const u_char *_msg, *_eom;
|
||||
uint16_t _id, _flags, _counts[ns_s_max];
|
||||
const u_char *_sections[ns_s_max];
|
||||
ns_sect _sect;
|
||||
int _rrnum;
|
||||
const u_char *_msg_ptr;
|
||||
} ns_msg;
|
||||
|
||||
/* Private data structure - do not use from outside library. */
|
||||
struct _ns_flagdata { int mask, shift; };
|
||||
extern const struct _ns_flagdata _ns_flagdata[];
|
||||
|
||||
/* Accessor macros - this is part of the public interface. */
|
||||
|
||||
#define ns_msg_id(handle) ((handle)._id + 0)
|
||||
#define ns_msg_base(handle) ((handle)._msg + 0)
|
||||
#define ns_msg_end(handle) ((handle)._eom + 0)
|
||||
#define ns_msg_size(handle) ((size_t)((handle)._eom - (handle)._msg))
|
||||
#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
|
||||
|
||||
/*
|
||||
* This is a parsed record. It is caller allocated and has no dynamic data.
|
||||
*/
|
||||
typedef struct __ns_rr {
|
||||
char name[NS_MAXDNAME];
|
||||
uint16_t type;
|
||||
uint16_t rr_class;
|
||||
uint32_t ttl;
|
||||
uint16_t rdlength;
|
||||
const u_char * rdata;
|
||||
} ns_rr;
|
||||
|
||||
/* Accessor macros - this is part of the public interface. */
|
||||
#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
|
||||
#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
|
||||
#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
|
||||
#define ns_rr_ttl(rr) ((u_long)(rr).ttl + 0)
|
||||
#define ns_rr_rdlen(rr) ((size_t)(rr).rdlength + 0)
|
||||
#define ns_rr_rdata(rr) ((rr).rdata + 0)
|
||||
|
||||
/*
|
||||
* These don't have to be in the same order as in the packet flags word,
|
||||
* and they can even overlap in some cases, but they will need to be kept
|
||||
* in synch with ns_parse.c:ns_flagdata[].
|
||||
*/
|
||||
typedef enum __ns_flag {
|
||||
ns_f_qr, /* Question/Response. */
|
||||
ns_f_opcode, /* Operation code. */
|
||||
ns_f_aa, /* Authoritative Answer. */
|
||||
ns_f_tc, /* Truncation occurred. */
|
||||
ns_f_rd, /* Recursion Desired. */
|
||||
ns_f_ra, /* Recursion Available. */
|
||||
ns_f_z, /* MBZ. */
|
||||
ns_f_ad, /* Authentic Data (DNSSEC). */
|
||||
ns_f_cd, /* Checking Disabled (DNSSEC). */
|
||||
ns_f_rcode, /* Response code. */
|
||||
ns_f_max
|
||||
} ns_flag;
|
||||
|
||||
/*
|
||||
* Currently defined opcodes.
|
||||
*/
|
||||
typedef enum __ns_opcode {
|
||||
ns_o_query = 0, /* Standard query. */
|
||||
ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */
|
||||
ns_o_status = 2, /* Name server status query (unsupported). */
|
||||
/* Opcode 3 is undefined/reserved. */
|
||||
ns_o_notify = 4, /* Zone change notification. */
|
||||
ns_o_update = 5, /* Zone update message. */
|
||||
ns_o_max = 6
|
||||
} ns_opcode;
|
||||
|
||||
/*
|
||||
* Currently defined response codes.
|
||||
*/
|
||||
typedef enum __ns_rcode {
|
||||
ns_r_noerror = 0, /* No error occurred. */
|
||||
ns_r_formerr = 1, /* Format error. */
|
||||
ns_r_servfail = 2, /* Server failure. */
|
||||
ns_r_nxdomain = 3, /* Name error. */
|
||||
ns_r_notimpl = 4, /* Unimplemented. */
|
||||
ns_r_refused = 5, /* Operation refused. */
|
||||
/* these are for BIND_UPDATE */
|
||||
ns_r_yxdomain = 6, /* Name exists */
|
||||
ns_r_yxrrset = 7, /* RRset exists */
|
||||
ns_r_nxrrset = 8, /* RRset does not exist */
|
||||
ns_r_notauth = 9, /* Not authoritative for zone */
|
||||
ns_r_notzone = 10, /* Zone of record different from zone section */
|
||||
ns_r_max = 11,
|
||||
/* The following are EDNS extended rcodes */
|
||||
ns_r_badvers = 16,
|
||||
/* The following are TSIG errors */
|
||||
ns_r_badsig = 16,
|
||||
ns_r_badkey = 17,
|
||||
ns_r_badtime = 18
|
||||
} ns_rcode;
|
||||
|
||||
/* BIND_UPDATE */
|
||||
typedef enum __ns_update_operation {
|
||||
ns_uop_delete = 0,
|
||||
ns_uop_add = 1,
|
||||
ns_uop_max = 2
|
||||
} ns_update_operation;
|
||||
|
||||
/*
|
||||
* This structure is used for TSIG authenticated messages
|
||||
*/
|
||||
struct ns_tsig_key {
|
||||
char name[NS_MAXDNAME], alg[NS_MAXDNAME];
|
||||
unsigned char *data;
|
||||
int len;
|
||||
};
|
||||
typedef struct ns_tsig_key ns_tsig_key;
|
||||
|
||||
/*
|
||||
* This structure is used for TSIG authenticated TCP messages
|
||||
*/
|
||||
struct ns_tcp_tsig_state {
|
||||
int counter;
|
||||
struct dst_key *key;
|
||||
void *ctx;
|
||||
unsigned char sig[NS_PACKETSZ];
|
||||
int siglen;
|
||||
};
|
||||
typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
|
||||
|
||||
#define NS_TSIG_FUDGE 300
|
||||
#define NS_TSIG_TCP_COUNT 100
|
||||
#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
|
||||
|
||||
#define NS_TSIG_ERROR_NO_TSIG -10
|
||||
#define NS_TSIG_ERROR_NO_SPACE -11
|
||||
#define NS_TSIG_ERROR_FORMERR -12
|
||||
|
||||
/*
|
||||
* Currently defined type values for resources and queries.
|
||||
*/
|
||||
typedef enum __ns_type {
|
||||
ns_t_invalid = 0, /* Cookie. */
|
||||
ns_t_a = 1, /* Host address. */
|
||||
ns_t_ns = 2, /* Authoritative server. */
|
||||
ns_t_md = 3, /* Mail destination. */
|
||||
ns_t_mf = 4, /* Mail forwarder. */
|
||||
ns_t_cname = 5, /* Canonical name. */
|
||||
ns_t_soa = 6, /* Start of authority zone. */
|
||||
ns_t_mb = 7, /* Mailbox domain name. */
|
||||
ns_t_mg = 8, /* Mail group member. */
|
||||
ns_t_mr = 9, /* Mail rename name. */
|
||||
ns_t_null = 10, /* Null resource record. */
|
||||
ns_t_wks = 11, /* Well known service. */
|
||||
ns_t_ptr = 12, /* Domain name pointer. */
|
||||
ns_t_hinfo = 13, /* Host information. */
|
||||
ns_t_minfo = 14, /* Mailbox information. */
|
||||
ns_t_mx = 15, /* Mail routing information. */
|
||||
ns_t_txt = 16, /* Text strings. */
|
||||
ns_t_rp = 17, /* Responsible person. */
|
||||
ns_t_afsdb = 18, /* AFS cell database. */
|
||||
ns_t_x25 = 19, /* X_25 calling address. */
|
||||
ns_t_isdn = 20, /* ISDN calling address. */
|
||||
ns_t_rt = 21, /* Router. */
|
||||
ns_t_nsap = 22, /* NSAP address. */
|
||||
ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */
|
||||
ns_t_sig = 24, /* Security signature. */
|
||||
ns_t_key = 25, /* Security key. */
|
||||
ns_t_px = 26, /* X.400 mail mapping. */
|
||||
ns_t_gpos = 27, /* Geographical position (withdrawn). */
|
||||
ns_t_aaaa = 28, /* Ip6 Address. */
|
||||
ns_t_loc = 29, /* Location Information. */
|
||||
ns_t_nxt = 30, /* Next domain (security). */
|
||||
ns_t_eid = 31, /* Endpoint identifier. */
|
||||
ns_t_nimloc = 32, /* Nimrod Locator. */
|
||||
ns_t_srv = 33, /* Server Selection. */
|
||||
ns_t_atma = 34, /* ATM Address */
|
||||
ns_t_naptr = 35, /* Naming Authority PoinTeR */
|
||||
ns_t_kx = 36, /* Key Exchange */
|
||||
ns_t_cert = 37, /* Certification record */
|
||||
ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
|
||||
ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
|
||||
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
|
||||
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
|
||||
ns_t_apl = 42, /* Address prefix list (RFC 3123) */
|
||||
ns_t_tkey = 249, /* Transaction key */
|
||||
ns_t_tsig = 250, /* Transaction signature. */
|
||||
ns_t_ixfr = 251, /* Incremental zone transfer. */
|
||||
ns_t_axfr = 252, /* Transfer zone of authority. */
|
||||
ns_t_mailb = 253, /* Transfer mailbox records. */
|
||||
ns_t_maila = 254, /* Transfer mail agent records. */
|
||||
ns_t_any = 255, /* Wildcard match. */
|
||||
ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
|
||||
ns_t_max = 65536
|
||||
} ns_type;
|
||||
|
||||
/* Exclusively a QTYPE? (not also an RTYPE) */
|
||||
#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
|
||||
(t) == ns_t_mailb || (t) == ns_t_maila)
|
||||
/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
|
||||
#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
|
||||
/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
|
||||
#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
|
||||
#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
|
||||
#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
|
||||
(t) == ns_t_zxfr)
|
||||
|
||||
/*
|
||||
* Values for class field
|
||||
*/
|
||||
typedef enum __ns_class {
|
||||
ns_c_invalid = 0, /* Cookie. */
|
||||
ns_c_in = 1, /* Internet. */
|
||||
ns_c_2 = 2, /* unallocated/unsupported. */
|
||||
ns_c_chaos = 3, /* MIT Chaos-net. */
|
||||
ns_c_hs = 4, /* MIT Hesiod. */
|
||||
/* Query class values which do not appear in resource records */
|
||||
ns_c_none = 254, /* for prereq. sections in update requests */
|
||||
ns_c_any = 255, /* Wildcard match. */
|
||||
ns_c_max = 65536
|
||||
} ns_class;
|
||||
|
||||
/* DNSSEC constants. */
|
||||
|
||||
typedef enum __ns_key_types {
|
||||
ns_kt_rsa = 1, /* key type RSA/MD5 */
|
||||
ns_kt_dh = 2, /* Diffie Hellman */
|
||||
ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */
|
||||
ns_kt_private = 254 /* Private key type starts with OID */
|
||||
} ns_key_types;
|
||||
|
||||
typedef enum __ns_cert_types {
|
||||
cert_t_pkix = 1, /* PKIX (X.509v3) */
|
||||
cert_t_spki = 2, /* SPKI */
|
||||
cert_t_pgp = 3, /* PGP */
|
||||
cert_t_url = 253, /* URL private type */
|
||||
cert_t_oid = 254 /* OID private type */
|
||||
} ns_cert_types;
|
||||
|
||||
/* Flags field of the KEY RR rdata. */
|
||||
#define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */
|
||||
#define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */
|
||||
#define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */
|
||||
#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */
|
||||
#define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */
|
||||
/* The type bits can also be interpreted independently, as single bits: */
|
||||
#define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */
|
||||
#define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */
|
||||
#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */
|
||||
#define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */
|
||||
#define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */
|
||||
#define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */
|
||||
#define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */
|
||||
#define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */
|
||||
#define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */
|
||||
#define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */
|
||||
#define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */
|
||||
#define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */
|
||||
#define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */
|
||||
#define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */
|
||||
#define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */
|
||||
#define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */
|
||||
#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
|
||||
NS_KEY_RESERVED4 | \
|
||||
NS_KEY_RESERVED5 | \
|
||||
NS_KEY_RESERVED8 | \
|
||||
NS_KEY_RESERVED9 | \
|
||||
NS_KEY_RESERVED10 | \
|
||||
NS_KEY_RESERVED11 )
|
||||
#define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */
|
||||
|
||||
/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
|
||||
#define NS_ALG_MD5RSA 1 /* MD5 with RSA */
|
||||
#define NS_ALG_DH 2 /* Diffie Hellman KEY */
|
||||
#define NS_ALG_DSA 3 /* DSA KEY */
|
||||
#define NS_ALG_DSS NS_ALG_DSA
|
||||
#define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */
|
||||
#define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */
|
||||
|
||||
/* Protocol values */
|
||||
/* value 0 is reserved */
|
||||
#define NS_KEY_PROT_TLS 1
|
||||
#define NS_KEY_PROT_EMAIL 2
|
||||
#define NS_KEY_PROT_DNSSEC 3
|
||||
#define NS_KEY_PROT_IPSEC 4
|
||||
#define NS_KEY_PROT_ANY 255
|
||||
|
||||
/* Signatures */
|
||||
#define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */
|
||||
#define NS_MD5RSA_MAX_BITS 4096
|
||||
/* Total of binary mod and exp */
|
||||
#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
|
||||
/* Max length of text sig block */
|
||||
#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
|
||||
#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
|
||||
#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
|
||||
|
||||
#define NS_DSA_SIG_SIZE 41
|
||||
#define NS_DSA_MIN_SIZE 213
|
||||
#define NS_DSA_MAX_BYTES 405
|
||||
|
||||
/* Offsets into SIG record rdata to find various values */
|
||||
#define NS_SIG_TYPE 0 /* Type flags */
|
||||
#define NS_SIG_ALG 2 /* Algorithm */
|
||||
#define NS_SIG_LABELS 3 /* How many labels in name */
|
||||
#define NS_SIG_OTTL 4 /* Original TTL */
|
||||
#define NS_SIG_EXPIR 8 /* Expiration time */
|
||||
#define NS_SIG_SIGNED 12 /* Signature time */
|
||||
#define NS_SIG_FOOT 16 /* Key footprint */
|
||||
#define NS_SIG_SIGNER 18 /* Domain name of who signed it */
|
||||
|
||||
/* How RR types are represented as bit-flags in NXT records */
|
||||
#define NS_NXT_BITS 8
|
||||
#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
|
||||
#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
|
||||
#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
|
||||
#define NS_NXT_MAX 127
|
||||
|
||||
/*
|
||||
* EDNS0 extended flags, host order.
|
||||
*/
|
||||
#define NS_OPT_DNSSEC_OK 0x8000U
|
||||
|
||||
/*
|
||||
* Inline versions of get/put short/long. Pointer is advanced.
|
||||
*/
|
||||
#define NS_GET16(s, cp) do { \
|
||||
const u_char *t_cp = (const u_char *)(cp); \
|
||||
(s) = ((uint16_t)t_cp[0] << 8) \
|
||||
| ((uint16_t)t_cp[1]) \
|
||||
; \
|
||||
(cp) += NS_INT16SZ; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define NS_GET32(l, cp) do { \
|
||||
const u_char *t_cp = (const u_char *)(cp); \
|
||||
(l) = ((uint32_t)t_cp[0] << 24) \
|
||||
| ((uint32_t)t_cp[1] << 16) \
|
||||
| ((uint32_t)t_cp[2] << 8) \
|
||||
| ((uint32_t)t_cp[3]) \
|
||||
; \
|
||||
(cp) += NS_INT32SZ; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define NS_PUT16(s, cp) do { \
|
||||
uint32_t t_s = (uint32_t)(s); \
|
||||
u_char *t_cp = (u_char *)(cp); \
|
||||
*t_cp++ = t_s >> 8; \
|
||||
*t_cp = t_s; \
|
||||
(cp) += NS_INT16SZ; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define NS_PUT32(l, cp) do { \
|
||||
uint32_t t_l = (uint32_t)(l); \
|
||||
u_char *t_cp = (u_char *)(cp); \
|
||||
*t_cp++ = t_l >> 24; \
|
||||
*t_cp++ = t_l >> 16; \
|
||||
*t_cp++ = t_l >> 8; \
|
||||
*t_cp = t_l; \
|
||||
(cp) += NS_INT32SZ; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
/*
|
||||
* ANSI C identifier hiding for bind's lib/nameser.
|
||||
*/
|
||||
#define ns_msg_getflag __ns_msg_getflag
|
||||
#define ns_get16 __ns_get16
|
||||
#define ns_get32 __ns_get32
|
||||
#define ns_put16 __ns_put16
|
||||
#define ns_put32 __ns_put32
|
||||
#define ns_initparse __ns_initparse
|
||||
#define ns_skiprr __ns_skiprr
|
||||
#define ns_parserr __ns_parserr
|
||||
#define ns_sprintrr __ns_sprintrr
|
||||
#define ns_sprintrrf __ns_sprintrrf
|
||||
#define ns_format_ttl __ns_format_ttl
|
||||
#define ns_parse_ttl __ns_parse_ttl
|
||||
#define ns_datetosecs __ns_datetosecs
|
||||
#define ns_name_ntol __ns_name_ntol
|
||||
#define ns_name_ntop __ns_name_ntop
|
||||
#define ns_name_pton __ns_name_pton
|
||||
#define ns_name_unpack __ns_name_unpack
|
||||
#define ns_name_pack __ns_name_pack
|
||||
#define ns_name_compress __ns_name_compress
|
||||
#define ns_name_uncompress __ns_name_uncompress
|
||||
#define ns_name_skip __ns_name_skip
|
||||
#define ns_name_rollback __ns_name_rollback
|
||||
#define ns_sign __ns_sign
|
||||
#define ns_sign2 __ns_sign2
|
||||
#define ns_sign_tcp __ns_sign_tcp
|
||||
#define ns_sign_tcp2 __ns_sign_tcp2
|
||||
#define ns_sign_tcp_init __ns_sign_tcp_init
|
||||
#define ns_find_tsig __ns_find_tsig
|
||||
#define ns_verify __ns_verify
|
||||
#define ns_verify_tcp __ns_verify_tcp
|
||||
#define ns_verify_tcp_init __ns_verify_tcp_init
|
||||
#define ns_samedomain __ns_samedomain
|
||||
#define ns_subdomain __ns_subdomain
|
||||
#define ns_makecanon __ns_makecanon
|
||||
#define ns_samename __ns_samename
|
||||
|
||||
__BEGIN_DECLS
|
||||
int ns_msg_getflag(ns_msg, int);
|
||||
uint16_t ns_get16(const u_char *);
|
||||
uint32_t ns_get32(const u_char *);
|
||||
void ns_put16(uint16_t, u_char *);
|
||||
void ns_put32(uint32_t, u_char *);
|
||||
int ns_initparse(const u_char *, int, ns_msg *);
|
||||
int ns_skiprr(const u_char *, const u_char *, ns_sect, int);
|
||||
int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
|
||||
int ns_sprintrr(const ns_msg *, const ns_rr *,
|
||||
const char *, const char *, char *, size_t);
|
||||
int ns_sprintrrf(const u_char *, size_t, const char *,
|
||||
ns_class, ns_type, u_long, const u_char *,
|
||||
size_t, const char *, const char *,
|
||||
char *, size_t);
|
||||
int ns_format_ttl(u_long, char *, size_t);
|
||||
int ns_parse_ttl(const char *, u_long *);
|
||||
uint32_t ns_datetosecs(const char *cp, int *errp);
|
||||
int ns_name_ntol(const u_char *, u_char *, size_t);
|
||||
int ns_name_ntop(const u_char *, char *, size_t);
|
||||
int ns_name_pton(const char *, u_char *, size_t);
|
||||
int ns_name_unpack(const u_char *, const u_char *,
|
||||
const u_char *, u_char *, size_t);
|
||||
int ns_name_pack(const u_char *, u_char *, int,
|
||||
const u_char **, const u_char **);
|
||||
int ns_name_uncompress(const u_char *, const u_char *,
|
||||
const u_char *, char *, size_t);
|
||||
int ns_name_compress(const char *, u_char *, size_t,
|
||||
const u_char **, const u_char **);
|
||||
int ns_name_skip(const u_char **, const u_char *);
|
||||
void ns_name_rollback(const u_char *, const u_char **,
|
||||
const u_char **);
|
||||
int ns_sign(u_char *, int *, int, int, void *,
|
||||
const u_char *, int, u_char *, int *, time_t);
|
||||
int ns_sign2(u_char *, int *, int, int, void *,
|
||||
const u_char *, int, u_char *, int *, time_t,
|
||||
u_char **, u_char **);
|
||||
int ns_sign_tcp(u_char *, int *, int, int,
|
||||
ns_tcp_tsig_state *, int);
|
||||
int ns_sign_tcp2(u_char *, int *, int, int,
|
||||
ns_tcp_tsig_state *, int,
|
||||
u_char **, u_char **);
|
||||
int ns_sign_tcp_init(void *, const u_char *, int,
|
||||
ns_tcp_tsig_state *);
|
||||
u_char *ns_find_tsig(u_char *, u_char *);
|
||||
int ns_verify(u_char *, int *, void *,
|
||||
const u_char *, int, u_char *, int *,
|
||||
time_t *, int);
|
||||
int ns_verify_tcp(u_char *, int *, ns_tcp_tsig_state *, int);
|
||||
int ns_verify_tcp_init(void *, const u_char *, int,
|
||||
ns_tcp_tsig_state *);
|
||||
int ns_samedomain(const char *, const char *);
|
||||
int ns_subdomain(const char *, const char *);
|
||||
int ns_makecanon(const char *, char *, size_t);
|
||||
int ns_samename(const char *, const char *);
|
||||
__END_DECLS
|
||||
|
||||
#ifdef BIND_4_COMPAT
|
||||
#include "arpa_nameser_compat.h"
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
# include <logd.h>
|
||||
# define XLOG(...) \
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
|
||||
#else
|
||||
#define XLOG(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#endif /* !_ARPA_NAMESER_H_ */
|
||||
@@ -1,246 +0,0 @@
|
||||
/* $NetBSD: nameser_compat.h,v 1.1.1.2 2004/11/07 01:28:27 christos Exp $ */
|
||||
|
||||
/* Copyright (c) 1983, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* from nameser.h 8.1 (Berkeley) 6/2/93
|
||||
* Id: nameser_compat.h,v 1.1.2.3.4.2 2004/07/01 04:43:41 marka Exp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#ifndef _ARPA_NAMESER_COMPAT_
|
||||
#define _ARPA_NAMESER_COMPAT_
|
||||
|
||||
#define __BIND 19950621 /* (DEAD) interface version stamp. */
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#if (BSD >= 199103)
|
||||
# include <machine/endian.h>
|
||||
#else
|
||||
#ifdef __linux
|
||||
# include <endian.h>
|
||||
#else
|
||||
#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
|
||||
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
|
||||
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
|
||||
|
||||
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
|
||||
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
|
||||
defined(__alpha__) || defined(__alpha) || \
|
||||
(defined(__Lynx__) && defined(__x86__))
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
|
||||
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
|
||||
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
|
||||
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
|
||||
defined(__hppa) || defined(__hp9000) || \
|
||||
defined(__hp9000s300) || defined(__hp9000s700) || \
|
||||
defined(__hp3000s900) || defined(__hpux) || defined(MPE) || \
|
||||
defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc) || \
|
||||
(defined(__Lynx__) && \
|
||||
(defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif
|
||||
#endif /* __linux */
|
||||
#endif /* BSD */
|
||||
#endif /* BYTE_ORDER */
|
||||
|
||||
#if !defined(BYTE_ORDER) || \
|
||||
(BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
|
||||
BYTE_ORDER != PDP_ENDIAN)
|
||||
/* you must determine what the correct bit order is for
|
||||
* your compiler - the next line is an intentional error
|
||||
* which will force your compiles to bomb until you fix
|
||||
* the above macros.
|
||||
*/
|
||||
#error "Undefined or invalid BYTE_ORDER";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure for query header. The order of the fields is machine- and
|
||||
* compiler-dependent, depending on the byte/bit order and the layout
|
||||
* of bit fields. We use bit fields only in int variables, as this
|
||||
* is all ANSI requires. This requires a somewhat confusing rearrangement.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned id :16; /* query identification number */
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
/* fields in third byte */
|
||||
unsigned qr: 1; /* response flag */
|
||||
unsigned opcode: 4; /* purpose of message */
|
||||
unsigned aa: 1; /* authoritive answer */
|
||||
unsigned tc: 1; /* truncated message */
|
||||
unsigned rd: 1; /* recursion desired */
|
||||
/* fields in fourth byte */
|
||||
unsigned ra: 1; /* recursion available */
|
||||
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
|
||||
unsigned ad: 1; /* authentic data from named */
|
||||
unsigned cd: 1; /* checking disabled by resolver */
|
||||
unsigned rcode :4; /* response code */
|
||||
#endif
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
|
||||
/* fields in third byte */
|
||||
unsigned rd :1; /* recursion desired */
|
||||
unsigned tc :1; /* truncated message */
|
||||
unsigned aa :1; /* authoritive answer */
|
||||
unsigned opcode :4; /* purpose of message */
|
||||
unsigned qr :1; /* response flag */
|
||||
/* fields in fourth byte */
|
||||
unsigned rcode :4; /* response code */
|
||||
unsigned cd: 1; /* checking disabled by resolver */
|
||||
unsigned ad: 1; /* authentic data from named */
|
||||
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
|
||||
unsigned ra :1; /* recursion available */
|
||||
#endif
|
||||
/* remaining bytes */
|
||||
unsigned qdcount :16; /* number of question entries */
|
||||
unsigned ancount :16; /* number of answer entries */
|
||||
unsigned nscount :16; /* number of authority entries */
|
||||
unsigned arcount :16; /* number of resource entries */
|
||||
} HEADER;
|
||||
|
||||
#define PACKETSZ NS_PACKETSZ
|
||||
#define MAXDNAME NS_MAXDNAME
|
||||
#define MAXCDNAME NS_MAXCDNAME
|
||||
#define MAXLABEL NS_MAXLABEL
|
||||
#define HFIXEDSZ NS_HFIXEDSZ
|
||||
#define QFIXEDSZ NS_QFIXEDSZ
|
||||
#define RRFIXEDSZ NS_RRFIXEDSZ
|
||||
#define INT32SZ NS_INT32SZ
|
||||
#define INT16SZ NS_INT16SZ
|
||||
#define INT8SZ NS_INT8SZ
|
||||
#define INADDRSZ NS_INADDRSZ
|
||||
#define IN6ADDRSZ NS_IN6ADDRSZ
|
||||
#define INDIR_MASK NS_CMPRSFLGS
|
||||
#define NAMESERVER_PORT NS_DEFAULTPORT
|
||||
|
||||
#define S_ZONE ns_s_zn
|
||||
#define S_PREREQ ns_s_pr
|
||||
#define S_UPDATE ns_s_ud
|
||||
#define S_ADDT ns_s_ar
|
||||
|
||||
#define QUERY ns_o_query
|
||||
#define IQUERY ns_o_iquery
|
||||
#define STATUS ns_o_status
|
||||
#define NS_NOTIFY_OP ns_o_notify
|
||||
#define NS_UPDATE_OP ns_o_update
|
||||
|
||||
#define NOERROR ns_r_noerror
|
||||
#define FORMERR ns_r_formerr
|
||||
#define SERVFAIL ns_r_servfail
|
||||
#define NXDOMAIN ns_r_nxdomain
|
||||
#define NOTIMP ns_r_notimpl
|
||||
#define REFUSED ns_r_refused
|
||||
#define YXDOMAIN ns_r_yxdomain
|
||||
#define YXRRSET ns_r_yxrrset
|
||||
#define NXRRSET ns_r_nxrrset
|
||||
#define NOTAUTH ns_r_notauth
|
||||
#define NOTZONE ns_r_notzone
|
||||
/*#define BADSIG ns_r_badsig*/
|
||||
/*#define BADKEY ns_r_badkey*/
|
||||
/*#define BADTIME ns_r_badtime*/
|
||||
|
||||
|
||||
#define DELETE ns_uop_delete
|
||||
#define ADD ns_uop_add
|
||||
|
||||
#define T_A ns_t_a
|
||||
#define T_NS ns_t_ns
|
||||
#define T_MD ns_t_md
|
||||
#define T_MF ns_t_mf
|
||||
#define T_CNAME ns_t_cname
|
||||
#define T_SOA ns_t_soa
|
||||
#define T_MB ns_t_mb
|
||||
#define T_MG ns_t_mg
|
||||
#define T_MR ns_t_mr
|
||||
#define T_NULL ns_t_null
|
||||
#define T_WKS ns_t_wks
|
||||
#define T_PTR ns_t_ptr
|
||||
#define T_HINFO ns_t_hinfo
|
||||
#define T_MINFO ns_t_minfo
|
||||
#define T_MX ns_t_mx
|
||||
#define T_TXT ns_t_txt
|
||||
#define T_RP ns_t_rp
|
||||
#define T_AFSDB ns_t_afsdb
|
||||
#define T_X25 ns_t_x25
|
||||
#define T_ISDN ns_t_isdn
|
||||
#define T_RT ns_t_rt
|
||||
#define T_NSAP ns_t_nsap
|
||||
#define T_NSAP_PTR ns_t_nsap_ptr
|
||||
#define T_SIG ns_t_sig
|
||||
#define T_KEY ns_t_key
|
||||
#define T_PX ns_t_px
|
||||
#define T_GPOS ns_t_gpos
|
||||
#define T_AAAA ns_t_aaaa
|
||||
#define T_LOC ns_t_loc
|
||||
#define T_NXT ns_t_nxt
|
||||
#define T_EID ns_t_eid
|
||||
#define T_NIMLOC ns_t_nimloc
|
||||
#define T_SRV ns_t_srv
|
||||
#define T_ATMA ns_t_atma
|
||||
#define T_NAPTR ns_t_naptr
|
||||
#define T_A6 ns_t_a6
|
||||
#define T_TSIG ns_t_tsig
|
||||
#define T_IXFR ns_t_ixfr
|
||||
#define T_AXFR ns_t_axfr
|
||||
#define T_MAILB ns_t_mailb
|
||||
#define T_MAILA ns_t_maila
|
||||
#define T_ANY ns_t_any
|
||||
|
||||
#define C_IN ns_c_in
|
||||
#define C_CHAOS ns_c_chaos
|
||||
#define C_HS ns_c_hs
|
||||
/* BIND_UPDATE */
|
||||
#define C_NONE ns_c_none
|
||||
#define C_ANY ns_c_any
|
||||
|
||||
#define GETSHORT NS_GET16
|
||||
#define GETLONG NS_GET32
|
||||
#define PUTSHORT NS_PUT16
|
||||
#define PUTLONG NS_PUT32
|
||||
|
||||
#endif /* _ARPA_NAMESER_COMPAT_ */
|
||||
@@ -1,134 +0,0 @@
|
||||
/* $NetBSD: assertions.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1997-1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Id: assertions.h,v 1.1.206.1 2004/03/09 08:33:30 marka Exp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#ifndef ASSERTIONS_H
|
||||
#define ASSERTIONS_H 1
|
||||
|
||||
typedef enum {
|
||||
assert_require, assert_ensure, assert_insist, assert_invariant
|
||||
} assertion_type;
|
||||
|
||||
typedef void (*assertion_failure_callback)(const char *, int, assertion_type,
|
||||
const char *, int);
|
||||
|
||||
extern assertion_failure_callback __assertion_failed;
|
||||
void set_assertion_failure_callback(assertion_failure_callback f);
|
||||
const char *assertion_type_to_text(assertion_type type);
|
||||
|
||||
#ifdef CHECK_ALL
|
||||
#define CHECK_REQUIRE 1
|
||||
#define CHECK_ENSURE 1
|
||||
#define CHECK_INSIST 1
|
||||
#define CHECK_INVARIANT 1
|
||||
#endif
|
||||
|
||||
#ifdef CHECK_NONE
|
||||
#define CHECK_REQUIRE 0
|
||||
#define CHECK_ENSURE 0
|
||||
#define CHECK_INSIST 0
|
||||
#define CHECK_INVARIANT 0
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_REQUIRE
|
||||
#define CHECK_REQUIRE 1
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_ENSURE
|
||||
#define CHECK_ENSURE 1
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_INSIST
|
||||
#define CHECK_INSIST 1
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_INVARIANT
|
||||
#define CHECK_INVARIANT 1
|
||||
#endif
|
||||
|
||||
#if CHECK_REQUIRE != 0
|
||||
#define REQUIRE(cond) \
|
||||
((void) ((cond) || \
|
||||
((__assertion_failed)(__FILE__, __LINE__, assert_require, \
|
||||
#cond, 0), 0)))
|
||||
#define REQUIRE_ERR(cond) \
|
||||
((void) ((cond) || \
|
||||
((__assertion_failed)(__FILE__, __LINE__, assert_require, \
|
||||
#cond, 1), 0)))
|
||||
#else
|
||||
#define REQUIRE(cond) ((void) (cond))
|
||||
#define REQUIRE_ERR(cond) ((void) (cond))
|
||||
#endif /* CHECK_REQUIRE */
|
||||
|
||||
#if CHECK_ENSURE != 0
|
||||
#define ENSURE(cond) \
|
||||
((void) ((cond) || \
|
||||
((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
|
||||
#cond, 0), 0)))
|
||||
#define ENSURE_ERR(cond) \
|
||||
((void) ((cond) || \
|
||||
((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
|
||||
#cond, 1), 0)))
|
||||
#else
|
||||
#define ENSURE(cond) ((void) (cond))
|
||||
#define ENSURE_ERR(cond) ((void) (cond))
|
||||
#endif /* CHECK_ENSURE */
|
||||
|
||||
#if CHECK_INSIST != 0
|
||||
#define INSIST(cond) \
|
||||
((void) ((cond) || \
|
||||
((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
|
||||
#cond, 0), 0)))
|
||||
#define INSIST_ERR(cond) \
|
||||
((void) ((cond) || \
|
||||
((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
|
||||
#cond, 1), 0)))
|
||||
#else
|
||||
#define INSIST(cond) ((void) (cond))
|
||||
#define INSIST_ERR(cond) ((void) (cond))
|
||||
#endif /* CHECK_INSIST */
|
||||
|
||||
#if CHECK_INVARIANT != 0
|
||||
#define INVARIANT(cond) \
|
||||
((void) ((cond) || \
|
||||
((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
|
||||
#cond, 0), 0)))
|
||||
#define INVARIANT_ERR(cond) \
|
||||
((void) ((cond) || \
|
||||
((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
|
||||
#cond, 1), 0)))
|
||||
#else
|
||||
#define INVARIANT(cond) ((void) (cond))
|
||||
#define INVARIANT_ERR(cond) ((void) (cond))
|
||||
#endif /* CHECK_INVARIANT */
|
||||
|
||||
#endif /* ASSERTIONS_H */
|
||||
@@ -1,192 +0,0 @@
|
||||
/* $NetBSD: dst.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#ifndef DST_H
|
||||
#define DST_H
|
||||
|
||||
#ifndef HAS_DST_KEY
|
||||
typedef struct dst_key {
|
||||
char *dk_key_name; /* name of the key */
|
||||
int dk_key_size; /* this is the size of the key in bits */
|
||||
int dk_proto; /* what protocols this key can be used for */
|
||||
int dk_alg; /* algorithm number from key record */
|
||||
u_int32_t dk_flags; /* and the flags of the public key */
|
||||
u_int16_t dk_id; /* identifier of the key */
|
||||
} DST_KEY;
|
||||
#endif /* HAS_DST_KEY */
|
||||
|
||||
/*
|
||||
* do not taint namespace
|
||||
*/
|
||||
#define dst_bsafe_init __dst_bsafe_init
|
||||
#define dst_buffer_to_key __dst_buffer_to_key
|
||||
#define dst_check_algorithm __dst_check_algorithm
|
||||
#define dst_compare_keys __dst_compare_keys
|
||||
#define dst_cylink_init __dst_cylink_init
|
||||
#define dst_dnskey_to_key __dst_dnskey_to_key
|
||||
#define dst_eay_dss_init __dst_eay_dss_init
|
||||
#define dst_free_key __dst_free_key
|
||||
#define dst_generate_key __dst_generate_key
|
||||
#define dst_hmac_md5_init __dst_hmac_md5_init
|
||||
#define dst_init __dst_init
|
||||
#define dst_key_to_buffer __dst_key_to_buffer
|
||||
#define dst_key_to_dnskey __dst_key_to_dnskey
|
||||
#define dst_read_key __dst_read_key
|
||||
#define dst_rsaref_init __dst_rsaref_init
|
||||
#define dst_s_build_filename __dst_s_build_filename
|
||||
#define dst_s_calculate_bits __dst_s_calculate_bits
|
||||
#define dst_s_conv_bignum_b64_to_u8 __dst_s_conv_bignum_b64_to_u8
|
||||
#define dst_s_conv_bignum_u8_to_b64 __dst_s_conv_bignum_u8_to_b64
|
||||
#define dst_s_dns_key_id __dst_s_dns_key_id
|
||||
#define dst_s_dump __dst_s_dump
|
||||
#define dst_s_filename_length __dst_s_filename_length
|
||||
#define dst_s_fopen __dst_s_fopen
|
||||
#define dst_s_get_int16 __dst_s_get_int16
|
||||
#define dst_s_get_int32 __dst_s_get_int32
|
||||
#define dst_s_id_calc __dst_s_id_calc
|
||||
#define dst_s_put_int16 __dst_s_put_int16
|
||||
#define dst_s_put_int32 __dst_s_put_int32
|
||||
#define dst_s_quick_random __dst_s_quick_random
|
||||
#define dst_s_quick_random_set __dst_s_quick_random_set
|
||||
#define dst_s_random __dst_s_random
|
||||
#define dst_s_semi_random __dst_s_semi_random
|
||||
#define dst_s_verify_str __dst_s_verify_str
|
||||
#define dst_sig_size __dst_sig_size
|
||||
#define dst_sign_data __dst_sign_data
|
||||
#define dst_verify_data __dst_verify_data
|
||||
#define dst_write_key __dst_write_key
|
||||
|
||||
/*
|
||||
* DST Crypto API defintions
|
||||
*/
|
||||
void dst_init(void);
|
||||
int dst_check_algorithm(const int);
|
||||
|
||||
int dst_sign_data(const int, /* specifies INIT/UPDATE/FINAL/ALL */
|
||||
DST_KEY *, /* the key to use */
|
||||
void **, /* pointer to state structure */
|
||||
const u_char *, /* data to be signed */
|
||||
const int, /* length of input data */
|
||||
u_char *, /* buffer to write signature to */
|
||||
const int); /* size of output buffer */
|
||||
|
||||
int dst_verify_data(const int, /* specifies INIT/UPDATE/FINAL/ALL */
|
||||
DST_KEY *, /* the key to use */
|
||||
void **, /* pointer to state structure */
|
||||
const u_char *, /* data to be verified */
|
||||
const int, /* length of input data */
|
||||
const u_char *, /* buffer containing signature */
|
||||
const int); /* length of signature */
|
||||
|
||||
|
||||
DST_KEY *dst_read_key(const char *, /* name of key */
|
||||
const u_int16_t, /* key tag identifier */
|
||||
const int, /* key algorithm */
|
||||
const int); /* Private/PublicKey wanted*/
|
||||
|
||||
int dst_write_key(const DST_KEY *, /* key to write out */
|
||||
const int); /* Public/Private */
|
||||
|
||||
DST_KEY *dst_dnskey_to_key(const char *, /* KEY record name */
|
||||
const u_char *, /* KEY RDATA */
|
||||
const int); /* size of input buffer*/
|
||||
|
||||
|
||||
int dst_key_to_dnskey(const DST_KEY *, /* key to translate */
|
||||
u_char *, /* output buffer */
|
||||
const int); /* size of out_storage*/
|
||||
|
||||
|
||||
DST_KEY *dst_buffer_to_key(const char *, /* name of the key */
|
||||
const int, /* algorithm */
|
||||
const int, /* dns flags */
|
||||
const int, /* dns protocol */
|
||||
const u_char *, /* key in dns wire fmt */
|
||||
const int); /* size of key */
|
||||
|
||||
|
||||
int dst_key_to_buffer(DST_KEY *, u_char *, int);
|
||||
|
||||
DST_KEY *dst_generate_key(const char *, /* name of new key */
|
||||
const int, /* key algorithm to generate */
|
||||
const int, /* size of new key */
|
||||
const int, /* alg dependent parameter*/
|
||||
const int, /* key DNS flags */
|
||||
const int); /* key DNS protocol */
|
||||
|
||||
DST_KEY *dst_free_key(DST_KEY *);
|
||||
int dst_compare_keys(const DST_KEY *, const DST_KEY *);
|
||||
|
||||
int dst_sig_size(DST_KEY *);
|
||||
|
||||
|
||||
/* support for dns key tags/ids */
|
||||
u_int16_t dst_s_dns_key_id(const u_char *, const int);
|
||||
u_int16_t dst_s_id_calc(const u_char *, const int);
|
||||
|
||||
/* Used by callers as well as by the library. */
|
||||
#define RAW_KEY_SIZE 8192 /* large enough to store any key */
|
||||
|
||||
/* DST_API control flags */
|
||||
/* These are used used in functions dst_sign_data and dst_verify_data */
|
||||
#define SIG_MODE_INIT 1 /* initialize digest */
|
||||
#define SIG_MODE_UPDATE 2 /* add data to digest */
|
||||
#define SIG_MODE_FINAL 4 /* generate/verify signature */
|
||||
#define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
|
||||
|
||||
/* Flags for dst_read_private_key() */
|
||||
#define DST_FORCE_READ 0x1000000
|
||||
#define DST_CAN_SIGN 0x010F
|
||||
#define DST_NO_AUTHEN 0x8000
|
||||
#define DST_EXTEND_FLAG 0x1000
|
||||
#define DST_STANDARD 0
|
||||
#define DST_PRIVATE 0x2000000
|
||||
#define DST_PUBLIC 0x4000000
|
||||
#define DST_RAND_SEMI 1
|
||||
#define DST_RAND_STD 2
|
||||
#define DST_RAND_KEY 3
|
||||
#define DST_RAND_DSS 4
|
||||
|
||||
|
||||
/* DST algorithm codes */
|
||||
#define KEY_RSA 1
|
||||
#define KEY_DH 2
|
||||
#define KEY_DSA 3
|
||||
#define KEY_PRIVATE 254
|
||||
#define KEY_EXPAND 255
|
||||
#define KEY_HMAC_MD5 157
|
||||
#define KEY_HMAC_SHA1 158
|
||||
#define UNKNOWN_KEYALG 0
|
||||
#define DST_MAX_ALGS KEY_HMAC_SHA1
|
||||
|
||||
/* DST constants to locations in KEY record changes in new KEY record */
|
||||
#define DST_FLAGS_SIZE 2
|
||||
#define DST_KEY_PROT 2
|
||||
#define DST_KEY_ALG 3
|
||||
#define DST_EXT_FLAG 4
|
||||
#define DST_KEY_START 4
|
||||
|
||||
#ifndef SIGN_F_NOKEY
|
||||
#define SIGN_F_NOKEY 0xC000
|
||||
#endif
|
||||
|
||||
/* error codes from dst routines */
|
||||
#define SIGN_INIT_FAILURE (-23)
|
||||
#define SIGN_UPDATE_FAILURE (-24)
|
||||
#define SIGN_FINAL_FAILURE (-25)
|
||||
#define VERIFY_INIT_FAILURE (-26)
|
||||
#define VERIFY_UPDATE_FAILURE (-27)
|
||||
#define VERIFY_FINAL_FAILURE (-28)
|
||||
#define MISSING_KEY_OR_SIGNATURE (-30)
|
||||
#define UNSUPPORTED_KEYALG (-31)
|
||||
|
||||
#endif /* DST_H */
|
||||
@@ -1,328 +0,0 @@
|
||||
/* $NetBSD: ev_streams.c,v 1.2 2004/05/20 19:52:31 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996-1999 by Internet Software Consortium
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ev_streams.c - implement asynch stream file IO for the eventlib
|
||||
* vix 04mar96 [initial]
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#define ANDROID_CHANGES 1
|
||||
#define MOZILLA_NECKO_EXCLUDE_CODE 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(LINT) && !defined(CODECENTER) && !defined(lint)
|
||||
#ifdef notdef
|
||||
static const char rcsid[] = "Id: ev_streams.c,v 1.2.206.2 2004/03/17 00:29:51 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: ev_streams.c,v 1.2 2004/05/20 19:52:31 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "eventlib.h"
|
||||
#include "eventlib_p.h"
|
||||
|
||||
#ifndef MOZILLA_NECKO_EXCLUDE_CODE
|
||||
#ifndef _LIBC
|
||||
static int copyvec(evStream *str, const struct iovec *iov, int iocnt);
|
||||
static void consume(evStream *str, size_t bytes);
|
||||
static void done(evContext opaqueCtx, evStream *str);
|
||||
static void writable(evContext opaqueCtx, void *uap, int fd, int evmask);
|
||||
static void readable(evContext opaqueCtx, void *uap, int fd, int evmask);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct iovec
|
||||
evConsIovec(void *buf, size_t cnt) {
|
||||
struct iovec ret;
|
||||
|
||||
memset(&ret, 0xf5, sizeof ret);
|
||||
ret.iov_base = buf;
|
||||
ret.iov_len = cnt;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#ifndef MOZILLA_NECKO_EXCLUDE_CODE
|
||||
#ifndef _LIBC
|
||||
int
|
||||
evWrite(evContext opaqueCtx, int fd, const struct iovec *iov, int iocnt,
|
||||
evStreamFunc func, void *uap, evStreamID *id)
|
||||
{
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evStream *new;
|
||||
int save;
|
||||
|
||||
OKNEW(new);
|
||||
new->func = func;
|
||||
new->uap = uap;
|
||||
new->fd = fd;
|
||||
new->flags = 0;
|
||||
if (evSelectFD(opaqueCtx, fd, EV_WRITE, writable, new, &new->file) < 0)
|
||||
goto free;
|
||||
if (copyvec(new, iov, iocnt) < 0)
|
||||
goto free;
|
||||
new->prevDone = NULL;
|
||||
new->nextDone = NULL;
|
||||
if (ctx->streams != NULL)
|
||||
ctx->streams->prev = new;
|
||||
new->prev = NULL;
|
||||
new->next = ctx->streams;
|
||||
ctx->streams = new;
|
||||
if (id != NULL)
|
||||
id->opaque = new;
|
||||
return (0);
|
||||
free:
|
||||
save = errno;
|
||||
FREE(new);
|
||||
errno = save;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int
|
||||
evRead(evContext opaqueCtx, int fd, const struct iovec *iov, int iocnt,
|
||||
evStreamFunc func, void *uap, evStreamID *id)
|
||||
{
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evStream *new;
|
||||
int save;
|
||||
|
||||
OKNEW(new);
|
||||
new->func = func;
|
||||
new->uap = uap;
|
||||
new->fd = fd;
|
||||
new->flags = 0;
|
||||
if (evSelectFD(opaqueCtx, fd, EV_READ, readable, new, &new->file) < 0)
|
||||
goto free;
|
||||
if (copyvec(new, iov, iocnt) < 0)
|
||||
goto free;
|
||||
new->prevDone = NULL;
|
||||
new->nextDone = NULL;
|
||||
if (ctx->streams != NULL)
|
||||
ctx->streams->prev = new;
|
||||
new->prev = NULL;
|
||||
new->next = ctx->streams;
|
||||
ctx->streams = new;
|
||||
if (id)
|
||||
id->opaque = new;
|
||||
return (0);
|
||||
free:
|
||||
save = errno;
|
||||
FREE(new);
|
||||
errno = save;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int
|
||||
evTimeRW(evContext opaqueCtx, evStreamID id, evTimerID timer) /*ARGSUSED*/ {
|
||||
evStream *str = id.opaque;
|
||||
|
||||
UNUSED(opaqueCtx);
|
||||
|
||||
str->timer = timer;
|
||||
str->flags |= EV_STR_TIMEROK;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
evUntimeRW(evContext opaqueCtx, evStreamID id) /*ARGSUSED*/ {
|
||||
evStream *str = id.opaque;
|
||||
|
||||
UNUSED(opaqueCtx);
|
||||
|
||||
str->flags &= ~EV_STR_TIMEROK;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
evCancelRW(evContext opaqueCtx, evStreamID id) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evStream *old = id.opaque;
|
||||
|
||||
/*
|
||||
* The streams list is doubly threaded. First, there's ctx->streams
|
||||
* that's used by evDestroy() to find and cancel all streams. Second,
|
||||
* there's ctx->strDone (head) and ctx->strLast (tail) which thread
|
||||
* through the potentially smaller number of "IO completed" streams,
|
||||
* used in evGetNext() to avoid scanning the entire list.
|
||||
*/
|
||||
|
||||
/* Unlink from ctx->streams. */
|
||||
if (old->prev != NULL)
|
||||
old->prev->next = old->next;
|
||||
else
|
||||
ctx->streams = old->next;
|
||||
if (old->next != NULL)
|
||||
old->next->prev = old->prev;
|
||||
|
||||
/*
|
||||
* If 'old' is on the ctx->strDone list, remove it. Update
|
||||
* ctx->strLast if necessary.
|
||||
*/
|
||||
if (old->prevDone == NULL && old->nextDone == NULL) {
|
||||
/*
|
||||
* Either 'old' is the only item on the done list, or it's
|
||||
* not on the done list. If the former, then we unlink it
|
||||
* from the list. If the latter, we leave the list alone.
|
||||
*/
|
||||
if (ctx->strDone == old) {
|
||||
ctx->strDone = NULL;
|
||||
ctx->strLast = NULL;
|
||||
}
|
||||
} else {
|
||||
if (old->prevDone != NULL)
|
||||
old->prevDone->nextDone = old->nextDone;
|
||||
else
|
||||
ctx->strDone = old->nextDone;
|
||||
if (old->nextDone != NULL)
|
||||
old->nextDone->prevDone = old->prevDone;
|
||||
else
|
||||
ctx->strLast = old->prevDone;
|
||||
}
|
||||
|
||||
/* Deallocate the stream. */
|
||||
if (old->file.opaque)
|
||||
evDeselectFD(opaqueCtx, old->file);
|
||||
memput(old->iovOrig, sizeof (struct iovec) * old->iovOrigCount);
|
||||
FREE(old);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Copy a scatter/gather vector and initialize a stream handler's IO. */
|
||||
static int
|
||||
copyvec(evStream *str, const struct iovec *iov, int iocnt) {
|
||||
int i;
|
||||
|
||||
str->iovOrig = (struct iovec *)memget(sizeof(struct iovec) * iocnt);
|
||||
if (str->iovOrig == NULL) {
|
||||
errno = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
str->ioTotal = 0;
|
||||
for (i = 0; i < iocnt; i++) {
|
||||
str->iovOrig[i] = iov[i];
|
||||
str->ioTotal += iov[i].iov_len;
|
||||
}
|
||||
str->iovOrigCount = iocnt;
|
||||
str->iovCur = str->iovOrig;
|
||||
str->iovCurCount = str->iovOrigCount;
|
||||
str->ioDone = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Pull off or truncate lead iovec(s). */
|
||||
static void
|
||||
consume(evStream *str, size_t bytes) {
|
||||
while (bytes > 0U) {
|
||||
if (bytes < (size_t)str->iovCur->iov_len) {
|
||||
str->iovCur->iov_len -= bytes;
|
||||
str->iovCur->iov_base = (void *)
|
||||
((u_char *)str->iovCur->iov_base + bytes);
|
||||
str->ioDone += bytes;
|
||||
bytes = 0;
|
||||
} else {
|
||||
bytes -= str->iovCur->iov_len;
|
||||
str->ioDone += str->iovCur->iov_len;
|
||||
str->iovCur++;
|
||||
str->iovCurCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Add a stream to Done list and deselect the FD. */
|
||||
static void
|
||||
done(evContext opaqueCtx, evStream *str) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
|
||||
if (ctx->strLast != NULL) {
|
||||
str->prevDone = ctx->strLast;
|
||||
ctx->strLast->nextDone = str;
|
||||
ctx->strLast = str;
|
||||
} else {
|
||||
INSIST(ctx->strDone == NULL);
|
||||
ctx->strDone = ctx->strLast = str;
|
||||
}
|
||||
evDeselectFD(opaqueCtx, str->file);
|
||||
str->file.opaque = NULL;
|
||||
/* evDrop() will call evCancelRW() on us. */
|
||||
}
|
||||
|
||||
/* Dribble out some bytes on the stream. (Called by evDispatch().) */
|
||||
static void
|
||||
writable(evContext opaqueCtx, void *uap, int fd, int evmask) {
|
||||
evStream *str = uap;
|
||||
int bytes;
|
||||
|
||||
UNUSED(evmask);
|
||||
|
||||
bytes = writev(fd, str->iovCur, str->iovCurCount);
|
||||
if (bytes > 0) {
|
||||
if ((str->flags & EV_STR_TIMEROK) != 0)
|
||||
evTouchIdleTimer(opaqueCtx, str->timer);
|
||||
consume(str, bytes);
|
||||
} else {
|
||||
if (bytes < 0 && errno != EINTR) {
|
||||
str->ioDone = -1;
|
||||
str->ioErrno = errno;
|
||||
}
|
||||
}
|
||||
if (str->ioDone == -1 || str->ioDone == str->ioTotal)
|
||||
done(opaqueCtx, str);
|
||||
}
|
||||
|
||||
/* Scoop up some bytes from the stream. (Called by evDispatch().) */
|
||||
static void
|
||||
readable(evContext opaqueCtx, void *uap, int fd, int evmask) {
|
||||
evStream *str = uap;
|
||||
int bytes;
|
||||
|
||||
UNUSED(evmask);
|
||||
|
||||
bytes = readv(fd, str->iovCur, str->iovCurCount);
|
||||
if (bytes > 0) {
|
||||
if ((str->flags & EV_STR_TIMEROK) != 0)
|
||||
evTouchIdleTimer(opaqueCtx, str->timer);
|
||||
consume(str, bytes);
|
||||
} else {
|
||||
if (bytes == 0)
|
||||
str->ioDone = 0;
|
||||
else {
|
||||
if (errno != EINTR) {
|
||||
str->ioDone = -1;
|
||||
str->ioErrno = errno;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (str->ioDone <= 0 || str->ioDone == str->ioTotal)
|
||||
done(opaqueCtx, str);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,522 +0,0 @@
|
||||
/* $NetBSD: ev_timers.c,v 1.2 2004/05/20 19:52:31 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1995-1999 by Internet Software Consortium
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ev_timers.c - implement timers for the eventlib
|
||||
* vix 09sep95 [initial]
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#define ANDROID_CHANGES 1
|
||||
#define MOZILLA_NECKO_EXCLUDE_CODE 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(LINT) && !defined(CODECENTER) && !defined(lint)
|
||||
#ifdef notdef
|
||||
static const char rcsid[] = "Id: ev_timers.c,v 1.2.2.1.4.5 2004/03/17 02:39:13 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: ev_timers.c,v 1.2 2004/05/20 19:52:31 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Import. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "assertions.h"
|
||||
#include "eventlib.h"
|
||||
#include "eventlib_p.h"
|
||||
|
||||
/* Constants. */
|
||||
|
||||
#define MILLION 1000000
|
||||
#define BILLION 1000000000
|
||||
|
||||
/* Forward. */
|
||||
|
||||
#ifndef _LIBC
|
||||
static int due_sooner(void *, void *);
|
||||
static void set_index(void *, int);
|
||||
static void free_timer(void *, void *);
|
||||
static void print_timer(void *, void *);
|
||||
static void idle_timeout(evContext, void *, struct timespec, struct timespec);
|
||||
|
||||
/* Private type. */
|
||||
|
||||
typedef struct {
|
||||
evTimerFunc func;
|
||||
void * uap;
|
||||
struct timespec lastTouched;
|
||||
struct timespec max_idle;
|
||||
evTimer * timer;
|
||||
} idle_timer;
|
||||
#endif
|
||||
|
||||
/* Public. */
|
||||
|
||||
struct timespec
|
||||
evConsTime(time_t sec, long nsec) {
|
||||
struct timespec x;
|
||||
|
||||
x.tv_sec = sec;
|
||||
x.tv_nsec = nsec;
|
||||
return (x);
|
||||
}
|
||||
|
||||
struct timespec
|
||||
evAddTime(struct timespec addend1, struct timespec addend2) {
|
||||
struct timespec x;
|
||||
|
||||
x.tv_sec = addend1.tv_sec + addend2.tv_sec;
|
||||
x.tv_nsec = addend1.tv_nsec + addend2.tv_nsec;
|
||||
if (x.tv_nsec >= BILLION) {
|
||||
x.tv_sec++;
|
||||
x.tv_nsec -= BILLION;
|
||||
}
|
||||
return (x);
|
||||
}
|
||||
|
||||
struct timespec
|
||||
evSubTime(struct timespec minuend, struct timespec subtrahend) {
|
||||
struct timespec x;
|
||||
|
||||
x.tv_sec = minuend.tv_sec - subtrahend.tv_sec;
|
||||
if (minuend.tv_nsec >= subtrahend.tv_nsec)
|
||||
x.tv_nsec = minuend.tv_nsec - subtrahend.tv_nsec;
|
||||
else {
|
||||
x.tv_nsec = BILLION - subtrahend.tv_nsec + minuend.tv_nsec;
|
||||
x.tv_sec--;
|
||||
}
|
||||
return (x);
|
||||
}
|
||||
|
||||
int
|
||||
evCmpTime(struct timespec a, struct timespec b) {
|
||||
long x = a.tv_sec - b.tv_sec;
|
||||
|
||||
if (x == 0L)
|
||||
x = a.tv_nsec - b.tv_nsec;
|
||||
return (x < 0L ? (-1) : x > 0L ? (1) : (0));
|
||||
}
|
||||
|
||||
struct timespec
|
||||
evNowTime() {
|
||||
struct timeval now;
|
||||
#ifdef CLOCK_REALTIME
|
||||
struct timespec tsnow;
|
||||
int m = CLOCK_REALTIME;
|
||||
|
||||
#ifdef CLOCK_MONOTONIC
|
||||
if (__evOptMonoTime)
|
||||
m = CLOCK_MONOTONIC;
|
||||
#endif
|
||||
if (clock_gettime(m, &tsnow) == 0)
|
||||
return (tsnow);
|
||||
#endif
|
||||
if (gettimeofday(&now, NULL) < 0)
|
||||
return (evConsTime(0L, 0L));
|
||||
return (evTimeSpec(now));
|
||||
}
|
||||
|
||||
#ifndef MOZILLA_NECKO_EXCLUDE_CODE
|
||||
struct timespec
|
||||
evUTCTime(void) {
|
||||
struct timeval now;
|
||||
#ifdef CLOCK_REALTIME
|
||||
struct timespec tsnow;
|
||||
if (clock_gettime(CLOCK_REALTIME, &tsnow) == 0)
|
||||
return (tsnow);
|
||||
#endif
|
||||
if (gettimeofday(&now, NULL) < 0)
|
||||
return (evConsTime(0L, 0L));
|
||||
return (evTimeSpec(now));
|
||||
}
|
||||
|
||||
#ifndef _LIBC
|
||||
struct timespec
|
||||
evLastEventTime(evContext opaqueCtx) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
|
||||
return (ctx->lastEventTime);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct timespec
|
||||
evTimeSpec(struct timeval tv) {
|
||||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = tv.tv_sec;
|
||||
ts.tv_nsec = tv.tv_usec * 1000;
|
||||
return (ts);
|
||||
}
|
||||
|
||||
#ifndef MOZILLA_NECKO_EXCLUDE_CODE
|
||||
struct timeval
|
||||
evTimeVal(struct timespec ts) {
|
||||
struct timeval tv;
|
||||
|
||||
tv.tv_sec = ts.tv_sec;
|
||||
tv.tv_usec = ts.tv_nsec / 1000;
|
||||
return (tv);
|
||||
}
|
||||
|
||||
#ifndef _LIBC
|
||||
int
|
||||
evSetTimer(evContext opaqueCtx,
|
||||
evTimerFunc func,
|
||||
void *uap,
|
||||
struct timespec due,
|
||||
struct timespec inter,
|
||||
evTimerID *opaqueID
|
||||
) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evTimer *id;
|
||||
|
||||
printf("evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n",
|
||||
ctx, func, uap,
|
||||
(long)due.tv_sec, due.tv_nsec,
|
||||
(long)inter.tv_sec, inter.tv_nsec);
|
||||
|
||||
#ifdef __hpux
|
||||
/*
|
||||
* tv_sec and tv_nsec are unsigned.
|
||||
*/
|
||||
if (due.tv_nsec >= BILLION)
|
||||
EV_ERR(EINVAL);
|
||||
|
||||
if (inter.tv_nsec >= BILLION)
|
||||
EV_ERR(EINVAL);
|
||||
#else
|
||||
if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION)
|
||||
EV_ERR(EINVAL);
|
||||
|
||||
if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION)
|
||||
EV_ERR(EINVAL);
|
||||
#endif
|
||||
|
||||
/* due={0,0} is a magic cookie meaning "now." */
|
||||
if (due.tv_sec == (time_t)0 && due.tv_nsec == 0L)
|
||||
due = evNowTime();
|
||||
|
||||
/* Allocate and fill. */
|
||||
OKNEW(id);
|
||||
id->func = func;
|
||||
id->uap = uap;
|
||||
id->due = due;
|
||||
id->inter = inter;
|
||||
|
||||
if (heap_insert(ctx->timers, id) < 0)
|
||||
return (-1);
|
||||
|
||||
/* Remember the ID if the caller provided us a place for it. */
|
||||
if (opaqueID)
|
||||
opaqueID->opaque = id;
|
||||
|
||||
if (ctx->debug > 7) {
|
||||
printf("timers after evSetTimer:\n");
|
||||
(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
evClearTimer(evContext opaqueCtx, evTimerID id) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evTimer *del = id.opaque;
|
||||
|
||||
if (ctx->cur != NULL &&
|
||||
ctx->cur->type == Timer &&
|
||||
ctx->cur->u.timer.this == del) {
|
||||
printf("deferring delete of timer (executing)\n");
|
||||
/*
|
||||
* Setting the interval to zero ensures that evDrop() will
|
||||
* clean up the timer.
|
||||
*/
|
||||
del->inter = evConsTime(0, 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (heap_element(ctx->timers, del->index) != del)
|
||||
EV_ERR(ENOENT);
|
||||
|
||||
if (heap_delete(ctx->timers, del->index) < 0)
|
||||
return (-1);
|
||||
FREE(del);
|
||||
|
||||
if (ctx->debug > 7) {
|
||||
printf("timers after evClearTimer:\n");
|
||||
(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
evConfigTimer(evContext opaqueCtx,
|
||||
evTimerID id,
|
||||
const char *param,
|
||||
int value
|
||||
) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evTimer *timer = id.opaque;
|
||||
int result=0;
|
||||
|
||||
UNUSED(value);
|
||||
|
||||
if (heap_element(ctx->timers, timer->index) != timer)
|
||||
EV_ERR(ENOENT);
|
||||
|
||||
if (strcmp(param, "rate") == 0)
|
||||
timer->mode |= EV_TMR_RATE;
|
||||
else if (strcmp(param, "interval") == 0)
|
||||
timer->mode &= ~EV_TMR_RATE;
|
||||
else
|
||||
EV_ERR(EINVAL);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
int
|
||||
evResetTimer(evContext opaqueCtx,
|
||||
evTimerID id,
|
||||
evTimerFunc func,
|
||||
void *uap,
|
||||
struct timespec due,
|
||||
struct timespec inter
|
||||
) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evTimer *timer = id.opaque;
|
||||
struct timespec old_due;
|
||||
int result=0;
|
||||
|
||||
if (heap_element(ctx->timers, timer->index) != timer)
|
||||
EV_ERR(ENOENT);
|
||||
|
||||
#ifdef __hpux
|
||||
/*
|
||||
* tv_sec and tv_nsec are unsigned.
|
||||
*/
|
||||
if (due.tv_nsec >= BILLION)
|
||||
EV_ERR(EINVAL);
|
||||
|
||||
if (inter.tv_nsec >= BILLION)
|
||||
EV_ERR(EINVAL);
|
||||
#else
|
||||
if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION)
|
||||
EV_ERR(EINVAL);
|
||||
|
||||
if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION)
|
||||
EV_ERR(EINVAL);
|
||||
#endif
|
||||
|
||||
old_due = timer->due;
|
||||
|
||||
timer->func = func;
|
||||
timer->uap = uap;
|
||||
timer->due = due;
|
||||
timer->inter = inter;
|
||||
|
||||
switch (evCmpTime(due, old_due)) {
|
||||
case -1:
|
||||
result = heap_increased(ctx->timers, timer->index);
|
||||
break;
|
||||
case 0:
|
||||
result = 0;
|
||||
break;
|
||||
case 1:
|
||||
result = heap_decreased(ctx->timers, timer->index);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx->debug > 7) {
|
||||
printf("timers after evResetTimer:\n");
|
||||
(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
int
|
||||
evSetIdleTimer(evContext opaqueCtx,
|
||||
evTimerFunc func,
|
||||
void *uap,
|
||||
struct timespec max_idle,
|
||||
evTimerID *opaqueID
|
||||
) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
idle_timer *tt;
|
||||
|
||||
/* Allocate and fill. */
|
||||
OKNEW(tt);
|
||||
tt->func = func;
|
||||
tt->uap = uap;
|
||||
tt->lastTouched = ctx->lastEventTime;
|
||||
tt->max_idle = max_idle;
|
||||
|
||||
if (evSetTimer(opaqueCtx, idle_timeout, tt,
|
||||
evAddTime(ctx->lastEventTime, max_idle),
|
||||
max_idle, opaqueID) < 0) {
|
||||
FREE(tt);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
tt->timer = opaqueID->opaque;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
evClearIdleTimer(evContext opaqueCtx, evTimerID id) {
|
||||
evTimer *del = id.opaque;
|
||||
idle_timer *tt = del->uap;
|
||||
|
||||
FREE(tt);
|
||||
return (evClearTimer(opaqueCtx, id));
|
||||
}
|
||||
|
||||
int
|
||||
evResetIdleTimer(evContext opaqueCtx,
|
||||
evTimerID opaqueID,
|
||||
evTimerFunc func,
|
||||
void *uap,
|
||||
struct timespec max_idle
|
||||
) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evTimer *timer = opaqueID.opaque;
|
||||
idle_timer *tt = timer->uap;
|
||||
|
||||
tt->func = func;
|
||||
tt->uap = uap;
|
||||
tt->lastTouched = ctx->lastEventTime;
|
||||
tt->max_idle = max_idle;
|
||||
|
||||
return (evResetTimer(opaqueCtx, opaqueID, idle_timeout, tt,
|
||||
evAddTime(ctx->lastEventTime, max_idle),
|
||||
max_idle));
|
||||
}
|
||||
|
||||
int
|
||||
evTouchIdleTimer(evContext opaqueCtx, evTimerID id) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
evTimer *t = id.opaque;
|
||||
idle_timer *tt = t->uap;
|
||||
|
||||
tt->lastTouched = ctx->lastEventTime;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Public to the rest of eventlib. */
|
||||
|
||||
heap_context
|
||||
evCreateTimers(const evContext_p *ctx) {
|
||||
|
||||
UNUSED(ctx);
|
||||
|
||||
return (heap_new(due_sooner, set_index, 2048));
|
||||
}
|
||||
|
||||
void
|
||||
evDestroyTimers(const evContext_p *ctx) {
|
||||
(void) heap_for_each(ctx->timers, free_timer, NULL);
|
||||
(void) heap_free(ctx->timers);
|
||||
}
|
||||
|
||||
/* Private. */
|
||||
|
||||
static int
|
||||
due_sooner(void *a, void *b) {
|
||||
evTimer *a_timer, *b_timer;
|
||||
|
||||
a_timer = a;
|
||||
b_timer = b;
|
||||
return (evCmpTime(a_timer->due, b_timer->due) < 0);
|
||||
}
|
||||
|
||||
static void
|
||||
set_index(void *what, int idx) {
|
||||
evTimer *timer;
|
||||
|
||||
timer = what;
|
||||
timer->index = idx;
|
||||
}
|
||||
|
||||
static void
|
||||
free_timer(void *what, void *uap) {
|
||||
evTimer *t = what;
|
||||
|
||||
UNUSED(uap);
|
||||
|
||||
FREE(t);
|
||||
}
|
||||
|
||||
static void
|
||||
print_timer(void *what, void *uap) {
|
||||
evTimer *cur = what;
|
||||
evContext_p *ctx = uap;
|
||||
|
||||
cur = what;
|
||||
evPrintf(ctx, 7,
|
||||
" func %p, uap %p, due %ld.%09ld, inter %ld.%09ld\n",
|
||||
cur->func, cur->uap,
|
||||
(long)cur->due.tv_sec, cur->due.tv_nsec,
|
||||
(long)cur->inter.tv_sec, cur->inter.tv_nsec);
|
||||
}
|
||||
|
||||
static void
|
||||
idle_timeout(evContext opaqueCtx,
|
||||
void *uap,
|
||||
struct timespec due,
|
||||
struct timespec inter
|
||||
) {
|
||||
evContext_p *ctx = opaqueCtx.opaque;
|
||||
idle_timer *this = uap;
|
||||
struct timespec idle;
|
||||
|
||||
UNUSED(due);
|
||||
UNUSED(inter);
|
||||
|
||||
idle = evSubTime(ctx->lastEventTime, this->lastTouched);
|
||||
if (evCmpTime(idle, this->max_idle) >= 0) {
|
||||
(this->func)(opaqueCtx, this->uap, this->timer->due,
|
||||
this->max_idle);
|
||||
/*
|
||||
* Setting the interval to zero will cause the timer to
|
||||
* be cleaned up in evDrop().
|
||||
*/
|
||||
this->timer->inter = evConsTime(0L, 0L);
|
||||
FREE(this);
|
||||
} else {
|
||||
/* evDrop() will reschedule the timer. */
|
||||
this->timer->inter = evSubTime(this->max_idle, idle);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,214 +0,0 @@
|
||||
/* $NetBSD: eventlib.h,v 1.1.1.3 2005/12/21 23:15:22 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1995-1999 by Internet Software Consortium
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* eventlib.h - exported interfaces for eventlib
|
||||
* vix 09sep95 [initial]
|
||||
*
|
||||
* Id: eventlib.h,v 1.1.2.1.4.2 2005/07/28 07:43:18 marka Exp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#ifndef _EVENTLIB_H
|
||||
#define _EVENTLIB_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef __P
|
||||
# define __EVENTLIB_P_DEFINED
|
||||
# ifdef __STDC__
|
||||
# define __P(x) x
|
||||
# else
|
||||
# define __P(x) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* In the absence of branded types... */
|
||||
typedef struct { void *opaque; } evConnID;
|
||||
typedef struct { void *opaque; } evFileID;
|
||||
typedef struct { void *opaque; } evStreamID;
|
||||
typedef struct { void *opaque; } evTimerID;
|
||||
typedef struct { void *opaque; } evWaitID;
|
||||
typedef struct { void *opaque; } evContext;
|
||||
typedef struct { void *opaque; } evEvent;
|
||||
|
||||
#define evInitID(id) ((id)->opaque = NULL)
|
||||
#define evTestID(id) ((id).opaque != NULL)
|
||||
|
||||
typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
|
||||
const void *, int));
|
||||
typedef void (*evFileFunc)__P((evContext, void *, int, int));
|
||||
typedef void (*evStreamFunc)__P((evContext, void *, int, int));
|
||||
typedef void (*evTimerFunc)__P((evContext, void *,
|
||||
struct timespec, struct timespec));
|
||||
typedef void (*evWaitFunc)__P((evContext, void *, const void *));
|
||||
|
||||
typedef struct { unsigned char mask[256/8]; } evByteMask;
|
||||
#define EV_BYTEMASK_BYTE(b) ((b) / 8)
|
||||
#define EV_BYTEMASK_MASK(b) (1 << ((b) % 8))
|
||||
#define EV_BYTEMASK_SET(bm, b) \
|
||||
((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b))
|
||||
#define EV_BYTEMASK_CLR(bm, b) \
|
||||
((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b))
|
||||
#define EV_BYTEMASK_TST(bm, b) \
|
||||
((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b))
|
||||
|
||||
#define EV_POLL 1
|
||||
#define EV_WAIT 2
|
||||
#define EV_NULL 4
|
||||
|
||||
#define EV_READ 1
|
||||
#define EV_WRITE 2
|
||||
#define EV_EXCEPT 4
|
||||
|
||||
#define EV_WASNONBLOCKING 8 /* Internal library use. */
|
||||
|
||||
/* eventlib.c */
|
||||
#define evCreate __evCreate
|
||||
#define evSetDebug __evSetDebug
|
||||
#define evDestroy __evDestroy
|
||||
#define evGetNext __evGetNext
|
||||
#define evDispatch __evDispatch
|
||||
#define evDrop __evDrop
|
||||
#define evMainLoop __evMainLoop
|
||||
#define evHighestFD __evHighestFD
|
||||
#define evGetOption __evGetOption
|
||||
#define evSetOption __evSetOption
|
||||
|
||||
int evCreate __P((evContext *));
|
||||
void evSetDebug __P((evContext, int, FILE *));
|
||||
int evDestroy __P((evContext));
|
||||
int evGetNext __P((evContext, evEvent *, int));
|
||||
int evDispatch __P((evContext, evEvent));
|
||||
void evDrop __P((evContext, evEvent));
|
||||
int evMainLoop __P((evContext));
|
||||
int evHighestFD __P((evContext));
|
||||
int evGetOption __P((evContext *, const char *, int *));
|
||||
int evSetOption __P((evContext *, const char *, int));
|
||||
|
||||
/* ev_connects.c */
|
||||
#define evListen __evListen
|
||||
#define evConnect __evConnect
|
||||
#define evCancelConn __evCancelConn
|
||||
#define evHold __evHold
|
||||
#define evUnhold __evUnhold
|
||||
#define evTryAccept __evTryAccept
|
||||
|
||||
int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
|
||||
int evConnect __P((evContext, int, const void *, int,
|
||||
evConnFunc, void *, evConnID *));
|
||||
int evCancelConn __P((evContext, evConnID));
|
||||
int evHold __P((evContext, evConnID));
|
||||
int evUnhold __P((evContext, evConnID));
|
||||
int evTryAccept __P((evContext, evConnID, int *));
|
||||
|
||||
/* ev_files.c */
|
||||
#define evSelectFD __evSelectFD
|
||||
#define evDeselectFD __evDeselectFD
|
||||
|
||||
int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
|
||||
int evDeselectFD __P((evContext, evFileID));
|
||||
|
||||
/* ev_streams.c */
|
||||
#define evConsIovec __evConsIovec
|
||||
#define evWrite __evWrite
|
||||
#define evRead __evRead
|
||||
#define evTimeRW __evTimeRW
|
||||
#define evUntimeRW __evUntimeRW
|
||||
#define evCancelRW __evCancelRW
|
||||
|
||||
struct iovec evConsIovec __P((void *, size_t));
|
||||
int evWrite __P((evContext, int, const struct iovec *, int,
|
||||
evStreamFunc func, void *, evStreamID *));
|
||||
int evRead __P((evContext, int, const struct iovec *, int,
|
||||
evStreamFunc func, void *, evStreamID *));
|
||||
int evTimeRW __P((evContext, evStreamID, evTimerID timer));
|
||||
int evUntimeRW __P((evContext, evStreamID));
|
||||
int evCancelRW __P((evContext, evStreamID));
|
||||
|
||||
/* ev_timers.c */
|
||||
#define evConsTime __evConsTime
|
||||
#define evAddTime __evAddTime
|
||||
#define evSubTime __evSubTime
|
||||
#define evCmpTime __evCmpTime
|
||||
#define evTimeSpec __evTimeSpec
|
||||
#define evTimeVal __evTimeVal
|
||||
|
||||
#define evNowTime __evNowTime
|
||||
#define evUTCTime __evUTCTime
|
||||
#define evLastEventTime __evLastEventTime
|
||||
#define evSetTimer __evSetTimer
|
||||
#define evClearTimer __evClearTimer
|
||||
#define evConfigTimer __evConfigTimer
|
||||
#define evResetTimer __evResetTimer
|
||||
#define evSetIdleTimer __evSetIdleTimer
|
||||
#define evClearIdleTimer __evClearIdleTimer
|
||||
#define evResetIdleTimer __evResetIdleTimer
|
||||
#define evTouchIdleTimer __evTouchIdleTimer
|
||||
|
||||
struct timespec evConsTime __P((time_t sec, long nsec));
|
||||
struct timespec evAddTime __P((struct timespec, struct timespec));
|
||||
struct timespec evSubTime __P((struct timespec, struct timespec));
|
||||
struct timespec evNowTime __P((void));
|
||||
struct timespec evUTCTime __P((void));
|
||||
struct timespec evLastEventTime __P((evContext));
|
||||
struct timespec evTimeSpec __P((struct timeval));
|
||||
struct timeval evTimeVal __P((struct timespec));
|
||||
int evCmpTime __P((struct timespec, struct timespec));
|
||||
int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
|
||||
struct timespec, evTimerID *));
|
||||
int evClearTimer __P((evContext, evTimerID));
|
||||
int evConfigTimer __P((evContext, evTimerID, const char *param,
|
||||
int value));
|
||||
int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
|
||||
struct timespec, struct timespec));
|
||||
int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
|
||||
evTimerID *));
|
||||
int evClearIdleTimer __P((evContext, evTimerID));
|
||||
int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *,
|
||||
struct timespec));
|
||||
int evTouchIdleTimer __P((evContext, evTimerID));
|
||||
|
||||
/* ev_waits.c */
|
||||
#define evWaitFor __evWaitFor
|
||||
#define evDo __evDo
|
||||
#define evUnwait __evUnwait
|
||||
#define evDefer __evDefer
|
||||
|
||||
int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
|
||||
int evDo __P((evContext, const void *));
|
||||
int evUnwait __P((evContext, evWaitID));
|
||||
int evDefer __P((evContext, evWaitFunc, void *));
|
||||
|
||||
#ifdef __EVENTLIB_P_DEFINED
|
||||
# undef __P
|
||||
#endif
|
||||
|
||||
#endif /*_EVENTLIB_H*/
|
||||
@@ -1,243 +0,0 @@
|
||||
/* $NetBSD: eventlib_p.h,v 1.1.1.1 2004/05/20 19:34:32 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1995-1999 by Internet Software Consortium
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* eventlib_p.h - private interfaces for eventlib
|
||||
* vix 09sep95 [initial]
|
||||
*
|
||||
* Id: eventlib_p.h,v 1.3.2.1.4.1 2004/03/09 08:33:43 marka Exp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#ifndef _EVENTLIB_P_H
|
||||
#define _EVENTLIB_P_H
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#define EVENTLIB_DEBUG 1
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "heap.h"
|
||||
#include "list.h"
|
||||
#include "memcluster.h"
|
||||
|
||||
|
||||
#define EV_MASK_ALL (EV_READ | EV_WRITE | EV_EXCEPT)
|
||||
#define EV_ERR(e) return (errno = (e), -1)
|
||||
#define OK(x) if ((x) < 0) EV_ERR(errno); else (void)NULL
|
||||
|
||||
|
||||
#if HAVE_MEM_GET_SET
|
||||
#define NEW(p) if (((p) = memget(sizeof *(p))) != NULL) \
|
||||
FILL(p); \
|
||||
else \
|
||||
(void)NULL;
|
||||
#define OKNEW(p) if (!((p) = memget(sizeof *(p)))) { \
|
||||
errno = ENOMEM; \
|
||||
return (-1); \
|
||||
} else \
|
||||
FILL(p)
|
||||
#define FREE(p) memput((p), sizeof *(p))
|
||||
|
||||
#if EVENTLIB_DEBUG
|
||||
#define FILL(p) memset((p), 0xF5, sizeof *(p))
|
||||
#else
|
||||
#define FILL(p)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define NEW(p) p = malloc(sizeof *(p));
|
||||
#define OKNEW(p) if (!((p) = malloc(sizeof *(p)))) { errno = ENOMEM; return (-1); }
|
||||
#define FREE(p) free(p)
|
||||
#define FILL(p)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct evConn {
|
||||
evConnFunc func;
|
||||
void * uap;
|
||||
int fd;
|
||||
int flags;
|
||||
#define EV_CONN_LISTEN 0x0001 /* Connection is a listener. */
|
||||
#define EV_CONN_SELECTED 0x0002 /* evSelectFD(conn->file). */
|
||||
#define EV_CONN_BLOCK 0x0004 /* Listener fd was blocking. */
|
||||
evFileID file;
|
||||
struct evConn * prev;
|
||||
struct evConn * next;
|
||||
} evConn;
|
||||
|
||||
typedef struct evAccept {
|
||||
int fd;
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in in;
|
||||
#ifndef NO_SOCKADDR_UN
|
||||
struct sockaddr_un un;
|
||||
#endif
|
||||
} la;
|
||||
socklen_t lalen;
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in in;
|
||||
#ifndef NO_SOCKADDR_UN
|
||||
struct sockaddr_un un;
|
||||
#endif
|
||||
} ra;
|
||||
socklen_t ralen;
|
||||
int ioErrno;
|
||||
evConn * conn;
|
||||
LINK(struct evAccept) link;
|
||||
} evAccept;
|
||||
|
||||
typedef struct evFile {
|
||||
evFileFunc func;
|
||||
void * uap;
|
||||
int fd;
|
||||
int eventmask;
|
||||
int preemptive;
|
||||
struct evFile * prev;
|
||||
struct evFile * next;
|
||||
struct evFile * fdprev;
|
||||
struct evFile * fdnext;
|
||||
} evFile;
|
||||
|
||||
typedef struct evStream {
|
||||
evStreamFunc func;
|
||||
void * uap;
|
||||
evFileID file;
|
||||
evTimerID timer;
|
||||
int flags;
|
||||
#define EV_STR_TIMEROK 0x0001 /* IFF timer valid. */
|
||||
int fd;
|
||||
struct iovec * iovOrig;
|
||||
int iovOrigCount;
|
||||
struct iovec * iovCur;
|
||||
int iovCurCount;
|
||||
int ioTotal;
|
||||
int ioDone;
|
||||
int ioErrno;
|
||||
struct evStream *prevDone, *nextDone;
|
||||
struct evStream *prev, *next;
|
||||
} evStream;
|
||||
|
||||
typedef struct evTimer {
|
||||
evTimerFunc func;
|
||||
void * uap;
|
||||
struct timespec due, inter;
|
||||
int index;
|
||||
int mode;
|
||||
#define EV_TMR_RATE 1
|
||||
} evTimer;
|
||||
|
||||
typedef struct evWait {
|
||||
evWaitFunc func;
|
||||
void * uap;
|
||||
const void * tag;
|
||||
struct evWait * next;
|
||||
} evWait;
|
||||
|
||||
typedef struct evWaitList {
|
||||
evWait * first;
|
||||
evWait * last;
|
||||
struct evWaitList * prev;
|
||||
struct evWaitList * next;
|
||||
} evWaitList;
|
||||
|
||||
typedef struct evEvent_p {
|
||||
enum { Accept, File, Stream, Timer, Wait, Free, Null } type;
|
||||
union {
|
||||
struct { evAccept *this; } accept;
|
||||
struct { evFile *this; int eventmask; } file;
|
||||
struct { evStream *this; } stream;
|
||||
struct { evTimer *this; } timer;
|
||||
struct { evWait *this; } wait;
|
||||
struct { struct evEvent_p *next; } free;
|
||||
struct { const void *placeholder; } null;
|
||||
} u;
|
||||
} evEvent_p;
|
||||
|
||||
typedef struct {
|
||||
/* Global. */
|
||||
const evEvent_p *cur;
|
||||
/* Debugging. */
|
||||
int debug;
|
||||
FILE *output;
|
||||
/* Connections. */
|
||||
evConn *conns;
|
||||
LIST(evAccept) accepts;
|
||||
/* Files. */
|
||||
evFile *files, *fdNext;
|
||||
fd_set rdLast, rdNext;
|
||||
fd_set wrLast, wrNext;
|
||||
fd_set exLast, exNext;
|
||||
fd_set nonblockBefore;
|
||||
int fdMax, fdCount, highestFD;
|
||||
evFile *fdTable[FD_SETSIZE];
|
||||
#ifdef EVENTLIB_TIME_CHECKS
|
||||
struct timespec lastSelectTime;
|
||||
int lastFdCount;
|
||||
#endif
|
||||
/* Streams. */
|
||||
evStream *streams;
|
||||
evStream *strDone, *strLast;
|
||||
/* Timers. */
|
||||
struct timespec lastEventTime;
|
||||
heap_context timers;
|
||||
/* Waits. */
|
||||
evWaitList *waitLists;
|
||||
evWaitList waitDone;
|
||||
} evContext_p;
|
||||
|
||||
/* eventlib.c */
|
||||
#define evPrintf __evPrintf
|
||||
void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...);
|
||||
|
||||
/* ev_timers.c */
|
||||
#define evCreateTimers __evCreateTimers
|
||||
heap_context evCreateTimers(const evContext_p *);
|
||||
#define evDestroyTimers __evDestroyTimers
|
||||
void evDestroyTimers(const evContext_p *);
|
||||
|
||||
/* ev_waits.c */
|
||||
#define evFreeWait __evFreeWait
|
||||
evWait *evFreeWait(evContext_p *ctx, evWait *old);
|
||||
|
||||
/* Global options */
|
||||
int __evOptMonoTime;
|
||||
|
||||
#endif /*_EVENTLIB_P_H*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,59 +0,0 @@
|
||||
/* $NetBSD: heap.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1997,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
typedef int (*heap_higher_priority_func)(void *, void *);
|
||||
typedef void (*heap_index_func)(void *, int);
|
||||
typedef void (*heap_for_each_func)(void *, void *);
|
||||
|
||||
typedef struct heap_context {
|
||||
int array_size;
|
||||
int array_size_increment;
|
||||
int heap_size;
|
||||
void **heap;
|
||||
heap_higher_priority_func higher_priority;
|
||||
heap_index_func index;
|
||||
} *heap_context;
|
||||
|
||||
#define heap_new __heap_new
|
||||
#define heap_free __heap_free
|
||||
#define heap_insert __heap_insert
|
||||
#define heap_delete __heap_delete
|
||||
#define heap_increased __heap_increased
|
||||
#define heap_decreased __heap_decreased
|
||||
#define heap_element __heap_element
|
||||
#define heap_for_each __heap_for_each
|
||||
|
||||
heap_context heap_new(heap_higher_priority_func, heap_index_func, int);
|
||||
int heap_free(heap_context);
|
||||
int heap_insert(heap_context, void *);
|
||||
int heap_delete(heap_context, int);
|
||||
int heap_increased(heap_context, int);
|
||||
int heap_decreased(heap_context, int);
|
||||
void * heap_element(heap_context, int);
|
||||
int heap_for_each(heap_context, heap_for_each_func, void *);
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _LINKER_FORMAT_H
|
||||
#define _LINKER_FORMAT_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* Formatting routines for the dynamic linker's debug traces */
|
||||
/* We want to avoid dragging the whole C library fprintf() */
|
||||
/* implementation into the dynamic linker since this creates */
|
||||
/* issues (it uses malloc()/free()) and increases code size */
|
||||
|
||||
int format_buffer(char *buffer, size_t bufsize, const char *format, ...);
|
||||
|
||||
#endif /* _LINKER_FORMAT_H */
|
||||
@@ -1,124 +0,0 @@
|
||||
/* $NetBSD: list.h,v 1.2 2004/05/20 19:51:55 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1997,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#ifndef LIST_H
|
||||
#define LIST_H 1
|
||||
#include "assertions.h"
|
||||
|
||||
#define LIST(type) struct { type *head, *tail; }
|
||||
#define INIT_LIST(list) \
|
||||
do { (list).head = NULL; (list).tail = NULL; } while (/*CONSTCOND*/0)
|
||||
|
||||
#define LINK(type) struct { type *prev, *next; }
|
||||
#define INIT_LINK_TYPE(elt, link, type) \
|
||||
do { \
|
||||
(elt)->link.prev = (type *)(-1); \
|
||||
(elt)->link.next = (type *)(-1); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#define INIT_LINK(elt, link) \
|
||||
INIT_LINK_TYPE(elt, link, void)
|
||||
#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1))
|
||||
|
||||
#define HEAD(list) ((list).head)
|
||||
#define TAIL(list) ((list).tail)
|
||||
#define EMPTY(list) ((list).head == NULL)
|
||||
|
||||
#define PREPEND(list, elt, link) \
|
||||
do { \
|
||||
INSIST(!LINKED(elt, link));\
|
||||
if ((list).head != NULL) \
|
||||
(list).head->link.prev = (elt); \
|
||||
else \
|
||||
(list).tail = (elt); \
|
||||
(elt)->link.prev = NULL; \
|
||||
(elt)->link.next = (list).head; \
|
||||
(list).head = (elt); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define APPEND(list, elt, link) \
|
||||
do { \
|
||||
INSIST(!LINKED(elt, link));\
|
||||
if ((list).tail != NULL) \
|
||||
(list).tail->link.next = (elt); \
|
||||
else \
|
||||
(list).head = (elt); \
|
||||
(elt)->link.prev = (list).tail; \
|
||||
(elt)->link.next = NULL; \
|
||||
(list).tail = (elt); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define UNLINK_TYPE(list, elt, link, type) \
|
||||
do { \
|
||||
INSIST(LINKED(elt, link));\
|
||||
if ((elt)->link.next != NULL) \
|
||||
(elt)->link.next->link.prev = (elt)->link.prev; \
|
||||
else \
|
||||
(list).tail = (elt)->link.prev; \
|
||||
if ((elt)->link.prev != NULL) \
|
||||
(elt)->link.prev->link.next = (elt)->link.next; \
|
||||
else \
|
||||
(list).head = (elt)->link.next; \
|
||||
INIT_LINK_TYPE(elt, link, type); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#define UNLINK(list, elt, link) \
|
||||
UNLINK_TYPE(list, elt, link, void)
|
||||
|
||||
#define PREV(elt, link) ((elt)->link.prev)
|
||||
#define NEXT(elt, link) ((elt)->link.next)
|
||||
|
||||
#define INSERT_BEFORE(list, before, elt, link) \
|
||||
do { \
|
||||
INSIST(!LINKED(elt, link));\
|
||||
if ((before)->link.prev == NULL) \
|
||||
PREPEND(list, elt, link); \
|
||||
else { \
|
||||
(elt)->link.prev = (before)->link.prev; \
|
||||
(before)->link.prev = (elt); \
|
||||
(elt)->link.prev->link.next = (elt); \
|
||||
(elt)->link.next = (before); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define INSERT_AFTER(list, after, elt, link) \
|
||||
do { \
|
||||
INSIST(!LINKED(elt, link));\
|
||||
if ((after)->link.next == NULL) \
|
||||
APPEND(list, elt, link); \
|
||||
else { \
|
||||
(elt)->link.next = (after)->link.next; \
|
||||
(after)->link.next = (elt); \
|
||||
(elt)->link.next->link.prev = (elt); \
|
||||
(elt)->link.prev = (after); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define ENQUEUE(list, elt, link) APPEND(list, elt, link)
|
||||
#define DEQUEUE(list, elt, link) UNLINK(list, elt, link)
|
||||
|
||||
#endif /* LIST_H */
|
||||
@@ -1,61 +0,0 @@
|
||||
/* $NetBSD: memcluster.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1997,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#ifndef MEMCLUSTER_H
|
||||
#define MEMCLUSTER_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define meminit __meminit
|
||||
#ifdef MEMCLUSTER_DEBUG
|
||||
#define memget(s) __memget_debug(s, __FILE__, __LINE__)
|
||||
#define memput(p, s) __memput_debug(p, s, __FILE__, __LINE__)
|
||||
#else /*MEMCLUSTER_DEBUG*/
|
||||
#ifdef MEMCLUSTER_RECORD
|
||||
#define memget(s) __memget_record(s, __FILE__, __LINE__)
|
||||
#define memput(p, s) __memput_record(p, s, __FILE__, __LINE__)
|
||||
#else /*MEMCLUSTER_RECORD*/
|
||||
#define memget __memget
|
||||
#define memput __memput
|
||||
#endif /*MEMCLUSTER_RECORD*/
|
||||
#endif /*MEMCLUSTER_DEBUG*/
|
||||
#define memstats __memstats
|
||||
#define memactive __memactive
|
||||
|
||||
int meminit(size_t, size_t);
|
||||
void * __memget(size_t);
|
||||
void __memput(void *, size_t);
|
||||
void * __memget_debug(size_t, const char *, int);
|
||||
void __memput_debug(void *, size_t, const char *, int);
|
||||
void * __memget_record(size_t, const char *, int);
|
||||
void __memput_record(void *, size_t, const char *, int);
|
||||
void memstats(FILE *);
|
||||
int memactive(void);
|
||||
|
||||
#endif /* MEMCLUSTER_H */
|
||||
@@ -1,33 +0,0 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'ev_streams.c',
|
||||
'ev_timers.c',
|
||||
'getaddrinfo.c',
|
||||
'ns_name.c',
|
||||
'ns_netint.c',
|
||||
'ns_parse.c',
|
||||
'ns_samedomain.c',
|
||||
'ns_ttl.c',
|
||||
'res_comp.c',
|
||||
'res_data.c',
|
||||
'res_init.c',
|
||||
'res_send.c',
|
||||
]
|
||||
|
||||
# These files can't be unified because of conflicting global variable names.
|
||||
SOURCES += [
|
||||
'ns_print.c',
|
||||
'res_debug.c',
|
||||
'res_mkquery.c',
|
||||
'res_state.c',
|
||||
]
|
||||
|
||||
# We allow warnings for third-party code that can be updated from upstream.
|
||||
ALLOW_COMPILER_WARNINGS = True
|
||||
|
||||
FINAL_LIBRARY = 'mozglue'
|
||||
@@ -1,987 +0,0 @@
|
||||
/* $NetBSD: ns_name.c,v 1.3 2004/11/07 02:19:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#define ANDROID_CHANGES 1
|
||||
#define MOZILLA_NECKO_EXCLUDE_CODE 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#ifdef notdef
|
||||
static const char rcsid[] = "Id: ns_name.c,v 1.3.2.4.4.2 2004/05/04 03:27:47 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: ns_name.c,v 1.3 2004/11/07 02:19:49 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include "arpa_nameser.h"
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef ANDROID_CHANGES
|
||||
#include "resolv_private.h"
|
||||
#else
|
||||
#include <resolv.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef SPRINTF_CHAR
|
||||
# define SPRINTF(x) strlen(sprintf/**/x)
|
||||
#else
|
||||
# define SPRINTF(x) ((size_t)sprintf x)
|
||||
#endif
|
||||
|
||||
#define NS_TYPE_ELT 0x40 /* EDNS0 extended label type */
|
||||
#define DNS_LABELTYPE_BITSTRING 0x41
|
||||
|
||||
/* Data. */
|
||||
|
||||
static const char digits[] = "0123456789";
|
||||
|
||||
static const char digitvalue[256] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*16*/
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*32*/
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*48*/
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /*64*/
|
||||
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*80*/
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*96*/
|
||||
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*112*/
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*128*/
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*256*/
|
||||
};
|
||||
|
||||
/* Forward. */
|
||||
|
||||
static int special(int);
|
||||
static int printable(int);
|
||||
static int dn_find(const u_char *, const u_char *,
|
||||
const u_char * const *,
|
||||
const u_char * const *);
|
||||
static int encode_bitsring(const char **, const char *,
|
||||
unsigned char **, unsigned char **,
|
||||
unsigned const char *);
|
||||
static int labellen(const u_char *);
|
||||
static int decode_bitstring(const unsigned char **,
|
||||
char *, const char *);
|
||||
|
||||
/* Public. */
|
||||
|
||||
/*
|
||||
* ns_name_ntop(src, dst, dstsiz)
|
||||
* Convert an encoded domain name to printable ascii as per RFC1035.
|
||||
* return:
|
||||
* Number of bytes written to buffer, or -1 (with errno set)
|
||||
* notes:
|
||||
* The root is returned as "."
|
||||
* All other domains are returned in non absolute form
|
||||
*/
|
||||
int
|
||||
ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)
|
||||
{
|
||||
const u_char *cp;
|
||||
char *dn, *eom;
|
||||
u_char c;
|
||||
u_int n;
|
||||
int l;
|
||||
|
||||
cp = src;
|
||||
dn = dst;
|
||||
eom = dst + dstsiz;
|
||||
|
||||
while ((n = *cp++) != 0) {
|
||||
if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
|
||||
/* Some kind of compression pointer. */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
if (dn != dst) {
|
||||
if (dn >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '.';
|
||||
}
|
||||
if ((l = labellen(cp - 1)) < 0) {
|
||||
errno = EMSGSIZE; /* XXX */
|
||||
return(-1);
|
||||
}
|
||||
if (dn + l >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
if ((n & NS_CMPRSFLGS) == NS_TYPE_ELT) {
|
||||
int m;
|
||||
|
||||
if (n != DNS_LABELTYPE_BITSTRING) {
|
||||
/* XXX: labellen should reject this case */
|
||||
errno = EINVAL;
|
||||
return(-1);
|
||||
}
|
||||
if ((m = decode_bitstring(&cp, dn, eom)) < 0)
|
||||
{
|
||||
errno = EMSGSIZE;
|
||||
return(-1);
|
||||
}
|
||||
dn += m;
|
||||
continue;
|
||||
}
|
||||
for (; l > 0; l--) {
|
||||
c = *cp++;
|
||||
if (special(c)) {
|
||||
if (dn + 1 >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '\\';
|
||||
*dn++ = (char)c;
|
||||
} else if (!printable(c)) {
|
||||
if (dn + 3 >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '\\';
|
||||
*dn++ = digits[c / 100];
|
||||
*dn++ = digits[(c % 100) / 10];
|
||||
*dn++ = digits[c % 10];
|
||||
} else {
|
||||
if (dn >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = (char)c;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dn == dst) {
|
||||
if (dn >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '.';
|
||||
}
|
||||
if (dn >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '\0';
|
||||
return (dn - dst);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_pton(src, dst, dstsiz)
|
||||
* Convert a ascii string into an encoded domain name as per RFC1035.
|
||||
* return:
|
||||
* -1 if it fails
|
||||
* 1 if string was fully qualified
|
||||
* 0 is string was not fully qualified
|
||||
* notes:
|
||||
* Enforces label and domain length limits.
|
||||
*/
|
||||
|
||||
int
|
||||
ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
|
||||
{
|
||||
u_char *label, *bp, *eom;
|
||||
int c, n, escaped, e = 0;
|
||||
char *cp;
|
||||
|
||||
escaped = 0;
|
||||
bp = dst;
|
||||
eom = dst + dstsiz;
|
||||
label = bp++;
|
||||
|
||||
while ((c = *src++) != 0) {
|
||||
if (escaped) {
|
||||
if (c == '[') { /* start a bit string label */
|
||||
if ((cp = strchr(src, ']')) == NULL) {
|
||||
errno = EINVAL; /* ??? */
|
||||
return(-1);
|
||||
}
|
||||
if ((e = encode_bitsring(&src, cp + 2,
|
||||
&label, &bp, eom))
|
||||
!= 0) {
|
||||
errno = e;
|
||||
return(-1);
|
||||
}
|
||||
escaped = 0;
|
||||
label = bp++;
|
||||
if ((c = *src++) == 0)
|
||||
goto done;
|
||||
else if (c != '.') {
|
||||
errno = EINVAL;
|
||||
return(-1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if ((cp = strchr(digits, c)) != NULL) {
|
||||
n = (cp - digits) * 100;
|
||||
if ((c = *src++) == 0 ||
|
||||
(cp = strchr(digits, c)) == NULL) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
n += (cp - digits) * 10;
|
||||
if ((c = *src++) == 0 ||
|
||||
(cp = strchr(digits, c)) == NULL) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
n += (cp - digits);
|
||||
if (n > 255) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
c = n;
|
||||
}
|
||||
escaped = 0;
|
||||
} else if (c == '\\') {
|
||||
escaped = 1;
|
||||
continue;
|
||||
} else if (c == '.') {
|
||||
c = (bp - label - 1);
|
||||
if ((c & NS_CMPRSFLGS) != 0) { /* Label too big. */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
if (label >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*label = c;
|
||||
/* Fully qualified ? */
|
||||
if (*src == '\0') {
|
||||
if (c != 0) {
|
||||
if (bp >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*bp++ = '\0';
|
||||
}
|
||||
if ((bp - dst) > MAXCDNAME) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
if (c == 0 || *src == '.') {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
label = bp++;
|
||||
continue;
|
||||
}
|
||||
if (bp >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*bp++ = (u_char)c;
|
||||
}
|
||||
c = (bp - label - 1);
|
||||
if ((c & NS_CMPRSFLGS) != 0) { /* Label too big. */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
done:
|
||||
if (label >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*label = c;
|
||||
if (c != 0) {
|
||||
if (bp >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*bp++ = 0;
|
||||
}
|
||||
if ((bp - dst) > MAXCDNAME) { /* src too big */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef MOZILLA_NECKO_EXCLUDE_CODE
|
||||
/*
|
||||
* ns_name_ntol(src, dst, dstsiz)
|
||||
* Convert a network strings labels into all lowercase.
|
||||
* return:
|
||||
* Number of bytes written to buffer, or -1 (with errno set)
|
||||
* notes:
|
||||
* Enforces label and domain length limits.
|
||||
*/
|
||||
|
||||
int
|
||||
ns_name_ntol(const u_char *src, u_char *dst, size_t dstsiz)
|
||||
{
|
||||
const u_char *cp;
|
||||
u_char *dn, *eom;
|
||||
u_char c;
|
||||
u_int n;
|
||||
int l;
|
||||
|
||||
cp = src;
|
||||
dn = dst;
|
||||
eom = dst + dstsiz;
|
||||
|
||||
if (dn >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
while ((n = *cp++) != 0) {
|
||||
if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
|
||||
/* Some kind of compression pointer. */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = n;
|
||||
if ((l = labellen(cp - 1)) < 0) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
if (dn + l >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
for (; l > 0; l--) {
|
||||
c = *cp++;
|
||||
if (isupper(c))
|
||||
*dn++ = tolower(c);
|
||||
else
|
||||
*dn++ = c;
|
||||
}
|
||||
}
|
||||
*dn++ = '\0';
|
||||
return (dn - dst);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ns_name_unpack(msg, eom, src, dst, dstsiz)
|
||||
* Unpack a domain name from a message, source may be compressed.
|
||||
* return:
|
||||
* -1 if it fails, or consumed octets if it succeeds.
|
||||
*/
|
||||
int
|
||||
ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
|
||||
u_char *dst, size_t dstsiz)
|
||||
{
|
||||
const u_char *srcp, *dstlim;
|
||||
u_char *dstp;
|
||||
int n, len, checked, l;
|
||||
|
||||
len = -1;
|
||||
checked = 0;
|
||||
dstp = dst;
|
||||
srcp = src;
|
||||
dstlim = dst + dstsiz;
|
||||
if (srcp < msg || srcp >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
/* Fetch next label in domain name. */
|
||||
while ((n = *srcp++) != 0) {
|
||||
/* Check for indirection. */
|
||||
switch (n & NS_CMPRSFLGS) {
|
||||
case 0:
|
||||
case NS_TYPE_ELT:
|
||||
/* Limit checks. */
|
||||
if ((l = labellen(srcp - 1)) < 0) {
|
||||
errno = EMSGSIZE;
|
||||
return(-1);
|
||||
}
|
||||
if (dstp + l + 1 >= dstlim || srcp + l >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
checked += l + 1;
|
||||
*dstp++ = n;
|
||||
memcpy(dstp, srcp, (size_t)l);
|
||||
dstp += l;
|
||||
srcp += l;
|
||||
break;
|
||||
|
||||
case NS_CMPRSFLGS:
|
||||
if (srcp >= eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
if (len < 0)
|
||||
len = srcp - src + 1;
|
||||
srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
|
||||
if (srcp < msg || srcp >= eom) { /* Out of range. */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
checked += 2;
|
||||
/*
|
||||
* Check for loops in the compressed name;
|
||||
* if we've looked at the whole message,
|
||||
* there must be a loop.
|
||||
*/
|
||||
if (checked >= eom - msg) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EMSGSIZE;
|
||||
return (-1); /* flag error */
|
||||
}
|
||||
}
|
||||
*dstp = '\0';
|
||||
if (len < 0)
|
||||
len = srcp - src;
|
||||
return (len);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_pack(src, dst, dstsiz, dnptrs, lastdnptr)
|
||||
* Pack domain name 'domain' into 'comp_dn'.
|
||||
* return:
|
||||
* Size of the compressed name, or -1.
|
||||
* notes:
|
||||
* 'dnptrs' is an array of pointers to previous compressed names.
|
||||
* dnptrs[0] is a pointer to the beginning of the message. The array
|
||||
* ends with NULL.
|
||||
* 'lastdnptr' is a pointer to the end of the array pointed to
|
||||
* by 'dnptrs'.
|
||||
* Side effects:
|
||||
* The list of pointers in dnptrs is updated for labels inserted into
|
||||
* the message as we compress the name. If 'dnptr' is NULL, we don't
|
||||
* try to compress names. If 'lastdnptr' is NULL, we don't update the
|
||||
* list.
|
||||
*/
|
||||
int
|
||||
ns_name_pack(const u_char *src, u_char *dst, int dstsiz,
|
||||
const u_char **dnptrs, const u_char **lastdnptr)
|
||||
{
|
||||
u_char *dstp;
|
||||
const u_char **cpp, **lpp, *eob, *msg;
|
||||
const u_char *srcp;
|
||||
int n, l, first = 1;
|
||||
|
||||
srcp = src;
|
||||
dstp = dst;
|
||||
eob = dstp + dstsiz;
|
||||
lpp = cpp = NULL;
|
||||
if (dnptrs != NULL) {
|
||||
if ((msg = *dnptrs++) != NULL) {
|
||||
for (cpp = dnptrs; *cpp != NULL; cpp++)
|
||||
;
|
||||
lpp = cpp; /* end of list to search */
|
||||
}
|
||||
} else
|
||||
msg = NULL;
|
||||
|
||||
/* make sure the domain we are about to add is legal */
|
||||
l = 0;
|
||||
do {
|
||||
int l0;
|
||||
|
||||
n = *srcp;
|
||||
if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
if ((l0 = labellen(srcp)) < 0) {
|
||||
errno = EINVAL;
|
||||
return(-1);
|
||||
}
|
||||
l += l0 + 1;
|
||||
if (l > MAXCDNAME) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
srcp += l0 + 1;
|
||||
} while (n != 0);
|
||||
|
||||
/* from here on we need to reset compression pointer array on error */
|
||||
srcp = src;
|
||||
do {
|
||||
/* Look to see if we can use pointers. */
|
||||
n = *srcp;
|
||||
if (n != 0 && msg != NULL) {
|
||||
l = dn_find(srcp, msg, (const u_char * const *)dnptrs,
|
||||
(const u_char * const *)lpp);
|
||||
if (l >= 0) {
|
||||
if (dstp + 1 >= eob) {
|
||||
goto cleanup;
|
||||
}
|
||||
*dstp++ = ((u_int32_t)l >> 8) | NS_CMPRSFLGS;
|
||||
*dstp++ = l % 256;
|
||||
return (dstp - dst);
|
||||
}
|
||||
/* Not found, save it. */
|
||||
if (lastdnptr != NULL && cpp < lastdnptr - 1 &&
|
||||
(dstp - msg) < 0x4000 && first) {
|
||||
*cpp++ = dstp;
|
||||
*cpp = NULL;
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
/* copy label to buffer */
|
||||
if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
|
||||
/* Should not happen. */
|
||||
goto cleanup;
|
||||
}
|
||||
n = labellen(srcp);
|
||||
if (dstp + 1 + n >= eob) {
|
||||
goto cleanup;
|
||||
}
|
||||
memcpy(dstp, srcp, (size_t)(n + 1));
|
||||
srcp += n + 1;
|
||||
dstp += n + 1;
|
||||
} while (n != 0);
|
||||
|
||||
if (dstp > eob) {
|
||||
cleanup:
|
||||
if (msg != NULL)
|
||||
*lpp = NULL;
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
return (dstp - dst);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_uncompress(msg, eom, src, dst, dstsiz)
|
||||
* Expand compressed domain name to presentation format.
|
||||
* return:
|
||||
* Number of bytes read out of `src', or -1 (with errno set).
|
||||
* note:
|
||||
* Root domain returns as "." not "".
|
||||
*/
|
||||
int
|
||||
ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src,
|
||||
char *dst, size_t dstsiz)
|
||||
{
|
||||
u_char tmp[NS_MAXCDNAME];
|
||||
int n;
|
||||
|
||||
if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
|
||||
return (-1);
|
||||
if (ns_name_ntop(tmp, dst, dstsiz) == -1)
|
||||
return (-1);
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_compress(src, dst, dstsiz, dnptrs, lastdnptr)
|
||||
* Compress a domain name into wire format, using compression pointers.
|
||||
* return:
|
||||
* Number of bytes consumed in `dst' or -1 (with errno set).
|
||||
* notes:
|
||||
* 'dnptrs' is an array of pointers to previous compressed names.
|
||||
* dnptrs[0] is a pointer to the beginning of the message.
|
||||
* The list ends with NULL. 'lastdnptr' is a pointer to the end of the
|
||||
* array pointed to by 'dnptrs'. Side effect is to update the list of
|
||||
* pointers for labels inserted into the message as we compress the name.
|
||||
* If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
|
||||
* is NULL, we don't update the list.
|
||||
*/
|
||||
int
|
||||
ns_name_compress(const char *src, u_char *dst, size_t dstsiz,
|
||||
const u_char **dnptrs, const u_char **lastdnptr)
|
||||
{
|
||||
u_char tmp[NS_MAXCDNAME];
|
||||
|
||||
if (ns_name_pton(src, tmp, sizeof tmp) == -1)
|
||||
return (-1);
|
||||
return (ns_name_pack(tmp, dst, (int)dstsiz, dnptrs, lastdnptr));
|
||||
}
|
||||
|
||||
#ifndef MOZILLA_NECKO_EXCLUDE_CODE
|
||||
/*
|
||||
* Reset dnptrs so that there are no active references to pointers at or
|
||||
* after src.
|
||||
*/
|
||||
void
|
||||
ns_name_rollback(const u_char *src, const u_char **dnptrs,
|
||||
const u_char **lastdnptr)
|
||||
{
|
||||
while (dnptrs < lastdnptr && *dnptrs != NULL) {
|
||||
if (*dnptrs >= src) {
|
||||
*dnptrs = NULL;
|
||||
break;
|
||||
}
|
||||
dnptrs++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ns_name_skip(ptrptr, eom)
|
||||
* Advance *ptrptr to skip over the compressed name it points at.
|
||||
* return:
|
||||
* 0 on success, -1 (with errno set) on failure.
|
||||
*/
|
||||
int
|
||||
ns_name_skip(const u_char **ptrptr, const u_char *eom)
|
||||
{
|
||||
const u_char *cp;
|
||||
u_int n;
|
||||
int l;
|
||||
|
||||
cp = *ptrptr;
|
||||
while (cp < eom && (n = *cp++) != 0) {
|
||||
/* Check for indirection. */
|
||||
switch (n & NS_CMPRSFLGS) {
|
||||
case 0: /* normal case, n == len */
|
||||
cp += n;
|
||||
continue;
|
||||
case NS_TYPE_ELT: /* EDNS0 extended label */
|
||||
if ((l = labellen(cp - 1)) < 0) {
|
||||
errno = EMSGSIZE; /* XXX */
|
||||
return(-1);
|
||||
}
|
||||
cp += l;
|
||||
continue;
|
||||
case NS_CMPRSFLGS: /* indirection */
|
||||
cp++;
|
||||
break;
|
||||
default: /* illegal type */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (cp > eom) {
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
*ptrptr = cp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Private. */
|
||||
|
||||
/*
|
||||
* special(ch)
|
||||
* Thinking in noninternationalized USASCII (per the DNS spec),
|
||||
* is this characted special ("in need of quoting") ?
|
||||
* return:
|
||||
* boolean.
|
||||
*/
|
||||
static int
|
||||
special(int ch) {
|
||||
switch (ch) {
|
||||
case 0x22: /* '"' */
|
||||
case 0x2E: /* '.' */
|
||||
case 0x3B: /* ';' */
|
||||
case 0x5C: /* '\\' */
|
||||
case 0x28: /* '(' */
|
||||
case 0x29: /* ')' */
|
||||
/* Special modifiers in zone files. */
|
||||
case 0x40: /* '@' */
|
||||
case 0x24: /* '$' */
|
||||
return (1);
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* printable(ch)
|
||||
* Thinking in noninternationalized USASCII (per the DNS spec),
|
||||
* is this character visible and not a space when printed ?
|
||||
* return:
|
||||
* boolean.
|
||||
*/
|
||||
static int
|
||||
printable(int ch) {
|
||||
return (ch > 0x20 && ch < 0x7f);
|
||||
}
|
||||
|
||||
/*
|
||||
* Thinking in noninternationalized USASCII (per the DNS spec),
|
||||
* convert this character to lower case if it's upper case.
|
||||
*/
|
||||
static int
|
||||
mklower(int ch) {
|
||||
if (ch >= 0x41 && ch <= 0x5A)
|
||||
return (ch + 0x20);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
/*
|
||||
* dn_find(domain, msg, dnptrs, lastdnptr)
|
||||
* Search for the counted-label name in an array of compressed names.
|
||||
* return:
|
||||
* offset from msg if found, or -1.
|
||||
* notes:
|
||||
* dnptrs is the pointer to the first name on the list,
|
||||
* not the pointer to the start of the message.
|
||||
*/
|
||||
static int
|
||||
dn_find(const u_char *domain, const u_char *msg,
|
||||
const u_char * const *dnptrs,
|
||||
const u_char * const *lastdnptr)
|
||||
{
|
||||
const u_char *dn, *cp, *sp;
|
||||
const u_char * const *cpp;
|
||||
u_int n;
|
||||
|
||||
for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
|
||||
sp = *cpp;
|
||||
/*
|
||||
* terminate search on:
|
||||
* root label
|
||||
* compression pointer
|
||||
* unusable offset
|
||||
*/
|
||||
while (*sp != 0 && (*sp & NS_CMPRSFLGS) == 0 &&
|
||||
(sp - msg) < 0x4000) {
|
||||
dn = domain;
|
||||
cp = sp;
|
||||
while ((n = *cp++) != 0) {
|
||||
/*
|
||||
* check for indirection
|
||||
*/
|
||||
switch (n & NS_CMPRSFLGS) {
|
||||
case 0: /* normal case, n == len */
|
||||
n = labellen(cp - 1); /* XXX */
|
||||
|
||||
if (n != *dn++)
|
||||
goto next;
|
||||
|
||||
for (; n > 0; n--)
|
||||
if (mklower(*dn++) !=
|
||||
mklower(*cp++))
|
||||
goto next;
|
||||
/* Is next root for both ? */
|
||||
if (*dn == '\0' && *cp == '\0')
|
||||
return (sp - msg);
|
||||
if (*dn)
|
||||
continue;
|
||||
goto next;
|
||||
case NS_CMPRSFLGS: /* indirection */
|
||||
cp = msg + (((n & 0x3f) << 8) | *cp);
|
||||
break;
|
||||
|
||||
default: /* illegal type */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
next: ;
|
||||
sp += *sp + 1;
|
||||
}
|
||||
}
|
||||
errno = ENOENT;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
decode_bitstring(const unsigned char **cpp, char *dn, const char *eom)
|
||||
{
|
||||
const unsigned char *cp = *cpp;
|
||||
char *beg = dn, tc;
|
||||
int b, blen, plen, i;
|
||||
|
||||
if ((blen = (*cp & 0xff)) == 0)
|
||||
blen = 256;
|
||||
plen = (blen + 3) / 4;
|
||||
plen += sizeof("\\[x/]") + (blen > 99 ? 3 : (blen > 9) ? 2 : 1);
|
||||
if (dn + plen >= eom)
|
||||
return(-1);
|
||||
|
||||
cp++;
|
||||
i = SPRINTF((dn, "\\[x"));
|
||||
if (i < 0)
|
||||
return (-1);
|
||||
dn += i;
|
||||
for (b = blen; b > 7; b -= 8, cp++) {
|
||||
i = SPRINTF((dn, "%02x", *cp & 0xff));
|
||||
if (i < 0)
|
||||
return (-1);
|
||||
dn += i;
|
||||
}
|
||||
if (b > 4) {
|
||||
tc = *cp++;
|
||||
i = SPRINTF((dn, "%02x", tc & (0xff << (8 - b))));
|
||||
if (i < 0)
|
||||
return (-1);
|
||||
dn += i;
|
||||
} else if (b > 0) {
|
||||
tc = *cp++;
|
||||
i = SPRINTF((dn, "%1x",
|
||||
(((u_int32_t)tc >> 4) & 0x0f) & (0x0f << (4 - b))));
|
||||
if (i < 0)
|
||||
return (-1);
|
||||
dn += i;
|
||||
}
|
||||
i = SPRINTF((dn, "/%d]", blen));
|
||||
if (i < 0)
|
||||
return (-1);
|
||||
dn += i;
|
||||
|
||||
*cpp = cp;
|
||||
return(dn - beg);
|
||||
}
|
||||
|
||||
static int
|
||||
encode_bitsring(const char **bp, const char *end, unsigned char **labelp,
|
||||
unsigned char ** dst, unsigned const char *eom)
|
||||
{
|
||||
int afterslash = 0;
|
||||
const char *cp = *bp;
|
||||
unsigned char *tp;
|
||||
char c;
|
||||
const char *beg_blen;
|
||||
char *end_blen = NULL;
|
||||
int value = 0, count = 0, tbcount = 0, blen = 0;
|
||||
|
||||
beg_blen = end_blen = NULL;
|
||||
|
||||
/* a bitstring must contain at least 2 characters */
|
||||
if (end - cp < 2)
|
||||
return(EINVAL);
|
||||
|
||||
/* XXX: currently, only hex strings are supported */
|
||||
if (*cp++ != 'x')
|
||||
return(EINVAL);
|
||||
if (!isxdigit((*cp) & 0xff)) /* reject '\[x/BLEN]' */
|
||||
return(EINVAL);
|
||||
|
||||
for (tp = *dst + 1; cp < end && tp < eom; cp++) {
|
||||
switch((c = *cp)) {
|
||||
case ']': /* end of the bitstring */
|
||||
if (afterslash) {
|
||||
if (beg_blen == NULL)
|
||||
return(EINVAL);
|
||||
blen = (int)strtol(beg_blen, &end_blen, 10);
|
||||
if (*end_blen != ']')
|
||||
return(EINVAL);
|
||||
}
|
||||
if (count)
|
||||
*tp++ = ((value << 4) & 0xff);
|
||||
cp++; /* skip ']' */
|
||||
goto done;
|
||||
case '/':
|
||||
afterslash = 1;
|
||||
break;
|
||||
default:
|
||||
if (afterslash) {
|
||||
if (!isdigit(c&0xff))
|
||||
return(EINVAL);
|
||||
if (beg_blen == NULL) {
|
||||
|
||||
if (c == '0') {
|
||||
/* blen never begings with 0 */
|
||||
return(EINVAL);
|
||||
}
|
||||
beg_blen = cp;
|
||||
}
|
||||
} else {
|
||||
if (!isxdigit(c&0xff))
|
||||
return(EINVAL);
|
||||
value <<= 4;
|
||||
value += digitvalue[(int)c];
|
||||
count += 4;
|
||||
tbcount += 4;
|
||||
if (tbcount > 256)
|
||||
return(EINVAL);
|
||||
if (count == 8) {
|
||||
*tp++ = value;
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
done:
|
||||
if (cp >= end || tp >= eom)
|
||||
return(EMSGSIZE);
|
||||
|
||||
/*
|
||||
* bit length validation:
|
||||
* If a <length> is present, the number of digits in the <bit-data>
|
||||
* MUST be just sufficient to contain the number of bits specified
|
||||
* by the <length>. If there are insignificant bits in a final
|
||||
* hexadecimal or octal digit, they MUST be zero.
|
||||
* RFC 2673, Section 3.2.
|
||||
*/
|
||||
if (blen > 0) {
|
||||
int traillen;
|
||||
|
||||
if (((blen + 3) & ~3) != tbcount)
|
||||
return(EINVAL);
|
||||
traillen = tbcount - blen; /* between 0 and 3 */
|
||||
if (((value << (8 - traillen)) & 0xff) != 0)
|
||||
return(EINVAL);
|
||||
}
|
||||
else
|
||||
blen = tbcount;
|
||||
if (blen == 256)
|
||||
blen = 0;
|
||||
|
||||
/* encode the type and the significant bit fields */
|
||||
**labelp = DNS_LABELTYPE_BITSTRING;
|
||||
**dst = blen;
|
||||
|
||||
*bp = cp;
|
||||
*dst = tp;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int
|
||||
labellen(const u_char *lp)
|
||||
{
|
||||
int bitlen;
|
||||
u_char l = *lp;
|
||||
|
||||
if ((l & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
|
||||
/* should be avoided by the caller */
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if ((l & NS_CMPRSFLGS) == NS_TYPE_ELT) {
|
||||
if (l == DNS_LABELTYPE_BITSTRING) {
|
||||
if ((bitlen = *(lp + 1)) == 0)
|
||||
bitlen = 256;
|
||||
return((bitlen + 7 ) / 8 + 1);
|
||||
}
|
||||
return(-1); /* unknwon ELT */
|
||||
}
|
||||
return(l);
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/* $NetBSD: ns_netint.c,v 1.2 2004/05/20 20:19:00 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#define ANDROID_CHANGES 1
|
||||
#define MOZILLA_NECKO_EXCLUDE_CODE 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#ifdef notdef
|
||||
static const char rcsid[] = "Id: ns_netint.c,v 1.1.206.1 2004/03/09 08:33:44 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: ns_netint.c,v 1.2 2004/05/20 20:19:00 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Import. */
|
||||
|
||||
#include "arpa_nameser.h"
|
||||
|
||||
/* Public. */
|
||||
|
||||
u_int16_t
|
||||
ns_get16(const u_char *src) {
|
||||
u_int dst;
|
||||
|
||||
NS_GET16(dst, src);
|
||||
return (dst);
|
||||
}
|
||||
|
||||
u_int32_t
|
||||
ns_get32(const u_char *src) {
|
||||
u_long dst;
|
||||
|
||||
NS_GET32(dst, src);
|
||||
return (dst);
|
||||
}
|
||||
|
||||
void
|
||||
ns_put16(u_int16_t src, u_char *dst) {
|
||||
NS_PUT16(src, dst);
|
||||
}
|
||||
|
||||
void
|
||||
ns_put32(u_int32_t src, u_char *dst) {
|
||||
NS_PUT32(src, dst);
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
/* $NetBSD: ns_parse.c,v 1.2 2004/05/20 20:35:05 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#define ANDROID_CHANGES 1
|
||||
#define MOZILLA_NECKO_EXCLUDE_CODE 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#ifdef notdef
|
||||
static const char rcsid[] = "Id: ns_parse.c,v 1.3.2.1.4.1 2004/03/09 08:33:44 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: ns_parse.c,v 1.2 2004/05/20 20:35:05 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Import. */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include "arpa_nameser.h"
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef ANDROID_CHANGES
|
||||
#include "resolv_private.h"
|
||||
#else
|
||||
#include <resolv.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
/* Forward. */
|
||||
|
||||
static void setsection(ns_msg *msg, ns_sect sect);
|
||||
|
||||
/* Macros. */
|
||||
|
||||
#define RETERR(err) do { errno = (err); return (-1); } while (/*NOTREACHED*//*CONSTCOND*/0)
|
||||
|
||||
/* Public. */
|
||||
|
||||
/* These need to be in the same order as the nres.h:ns_flag enum. */
|
||||
const struct _ns_flagdata _ns_flagdata[16] = {
|
||||
{ 0x8000, 15 }, /* qr. */
|
||||
{ 0x7800, 11 }, /* opcode. */
|
||||
{ 0x0400, 10 }, /* aa. */
|
||||
{ 0x0200, 9 }, /* tc. */
|
||||
{ 0x0100, 8 }, /* rd. */
|
||||
{ 0x0080, 7 }, /* ra. */
|
||||
{ 0x0040, 6 }, /* z. */
|
||||
{ 0x0020, 5 }, /* ad. */
|
||||
{ 0x0010, 4 }, /* cd. */
|
||||
{ 0x000f, 0 }, /* rcode. */
|
||||
{ 0x0000, 0 }, /* expansion (1/6). */
|
||||
{ 0x0000, 0 }, /* expansion (2/6). */
|
||||
{ 0x0000, 0 }, /* expansion (3/6). */
|
||||
{ 0x0000, 0 }, /* expansion (4/6). */
|
||||
{ 0x0000, 0 }, /* expansion (5/6). */
|
||||
{ 0x0000, 0 }, /* expansion (6/6). */
|
||||
};
|
||||
|
||||
int ns_msg_getflag(ns_msg handle, int flag) {
|
||||
return((u_int32_t)((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift);
|
||||
}
|
||||
|
||||
int
|
||||
ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
|
||||
const u_char *optr = ptr;
|
||||
|
||||
for (; count > 0; count--) {
|
||||
int b, rdlength;
|
||||
|
||||
b = dn_skipname(ptr, eom);
|
||||
if (b < 0)
|
||||
RETERR(EMSGSIZE);
|
||||
ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/;
|
||||
if (section != ns_s_qd) {
|
||||
if (ptr + NS_INT32SZ + NS_INT16SZ > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
ptr += NS_INT32SZ/*TTL*/;
|
||||
NS_GET16(rdlength, ptr);
|
||||
ptr += rdlength/*RData*/;
|
||||
}
|
||||
}
|
||||
if (ptr > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
return (ptr - optr);
|
||||
}
|
||||
|
||||
int
|
||||
ns_initparse(const u_char *msg, int msglen, ns_msg *handle) {
|
||||
const u_char *eom = msg + msglen;
|
||||
int i;
|
||||
|
||||
memset(handle, 0x5e, sizeof *handle);
|
||||
handle->_msg = msg;
|
||||
handle->_eom = eom;
|
||||
if (msg + NS_INT16SZ > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
NS_GET16(handle->_id, msg);
|
||||
if (msg + NS_INT16SZ > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
NS_GET16(handle->_flags, msg);
|
||||
for (i = 0; i < ns_s_max; i++) {
|
||||
if (msg + NS_INT16SZ > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
NS_GET16(handle->_counts[i], msg);
|
||||
}
|
||||
for (i = 0; i < ns_s_max; i++)
|
||||
if (handle->_counts[i] == 0)
|
||||
handle->_sections[i] = NULL;
|
||||
else {
|
||||
int b = ns_skiprr(msg, eom, (ns_sect)i,
|
||||
handle->_counts[i]);
|
||||
|
||||
if (b < 0)
|
||||
return (-1);
|
||||
handle->_sections[i] = msg;
|
||||
msg += b;
|
||||
}
|
||||
if (msg != eom)
|
||||
RETERR(EMSGSIZE);
|
||||
setsection(handle, ns_s_max);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
|
||||
int b;
|
||||
|
||||
/* Make section right. */
|
||||
if ((unsigned)section >= (unsigned)ns_s_max)
|
||||
RETERR(ENODEV);
|
||||
if (section != handle->_sect)
|
||||
setsection(handle, section);
|
||||
|
||||
/* Make rrnum right. */
|
||||
if (rrnum == -1)
|
||||
rrnum = handle->_rrnum;
|
||||
if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
|
||||
RETERR(ENODEV);
|
||||
if (rrnum < handle->_rrnum)
|
||||
setsection(handle, section);
|
||||
if (rrnum > handle->_rrnum) {
|
||||
b = ns_skiprr(handle->_msg_ptr, handle->_eom, section,
|
||||
rrnum - handle->_rrnum);
|
||||
|
||||
if (b < 0)
|
||||
return (-1);
|
||||
handle->_msg_ptr += b;
|
||||
handle->_rrnum = rrnum;
|
||||
}
|
||||
|
||||
/* Do the parse. */
|
||||
b = dn_expand(handle->_msg, handle->_eom,
|
||||
handle->_msg_ptr, rr->name, NS_MAXDNAME);
|
||||
if (b < 0)
|
||||
return (-1);
|
||||
handle->_msg_ptr += b;
|
||||
if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
|
||||
RETERR(EMSGSIZE);
|
||||
NS_GET16(rr->type, handle->_msg_ptr);
|
||||
NS_GET16(rr->rr_class, handle->_msg_ptr);
|
||||
if (section == ns_s_qd) {
|
||||
rr->ttl = 0;
|
||||
rr->rdlength = 0;
|
||||
rr->rdata = NULL;
|
||||
} else {
|
||||
if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
|
||||
RETERR(EMSGSIZE);
|
||||
NS_GET32(rr->ttl, handle->_msg_ptr);
|
||||
NS_GET16(rr->rdlength, handle->_msg_ptr);
|
||||
if (handle->_msg_ptr + rr->rdlength > handle->_eom)
|
||||
RETERR(EMSGSIZE);
|
||||
rr->rdata = handle->_msg_ptr;
|
||||
handle->_msg_ptr += rr->rdlength;
|
||||
}
|
||||
if (++handle->_rrnum > handle->_counts[(int)section])
|
||||
setsection(handle, (ns_sect)((int)section + 1));
|
||||
|
||||
/* All done. */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Private. */
|
||||
|
||||
static void
|
||||
setsection(ns_msg *msg, ns_sect sect) {
|
||||
msg->_sect = sect;
|
||||
if (sect == ns_s_max) {
|
||||
msg->_rrnum = -1;
|
||||
msg->_msg_ptr = NULL;
|
||||
} else {
|
||||
msg->_rrnum = 0;
|
||||
msg->_msg_ptr = msg->_sections[(int)sect];
|
||||
}
|
||||
}
|
||||
@@ -1,928 +0,0 @@
|
||||
/* $NetBSD: ns_print.c,v 1.5 2004/11/07 02:19:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#define ANDROID_CHANGES 1
|
||||
#define MOZILLA_NECKO_EXCLUDE_CODE 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#ifdef notdef
|
||||
static const char rcsid[] = "Id: ns_print.c,v 1.3.2.1.4.5 2004/07/28 20:16:45 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: ns_print.c,v 1.5 2004/11/07 02:19:49 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Import. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include "arpa_nameser.h"
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "assertions.h"
|
||||
#include "dst.h"
|
||||
#include <errno.h>
|
||||
#ifdef ANDROID_CHANGES
|
||||
#include "resolv_private.h"
|
||||
#else
|
||||
#include <resolv.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef SPRINTF_CHAR
|
||||
# define SPRINTF(x) strlen(sprintf/**/x)
|
||||
#else
|
||||
# define SPRINTF(x) ((size_t)sprintf x)
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
/* Forward. */
|
||||
|
||||
static size_t prune_origin(const char *name, const char *origin);
|
||||
static int charstr(const u_char *rdata, const u_char *edata,
|
||||
char **buf, size_t *buflen);
|
||||
static int addname(const u_char *msg, size_t msglen,
|
||||
const u_char **p, const char *origin,
|
||||
char **buf, size_t *buflen);
|
||||
static void addlen(size_t len, char **buf, size_t *buflen);
|
||||
static int addstr(const char *src, size_t len,
|
||||
char **buf, size_t *buflen);
|
||||
static int addtab(size_t len, size_t target, int spaced,
|
||||
char **buf, size_t *buflen);
|
||||
|
||||
/* Macros. */
|
||||
|
||||
#define T(x) \
|
||||
do { \
|
||||
if ((x) < 0) \
|
||||
return (-1); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
/* Public. */
|
||||
|
||||
/*
|
||||
* int
|
||||
* ns_sprintrr(handle, rr, name_ctx, origin, buf, buflen)
|
||||
* Convert an RR to presentation format.
|
||||
* return:
|
||||
* Number of characters written to buf, or -1 (check errno).
|
||||
*/
|
||||
int
|
||||
ns_sprintrr(const ns_msg *handle, const ns_rr *rr,
|
||||
const char *name_ctx, const char *origin,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = ns_sprintrrf(ns_msg_base(*handle), ns_msg_size(*handle),
|
||||
ns_rr_name(*rr), ns_rr_class(*rr), ns_rr_type(*rr),
|
||||
ns_rr_ttl(*rr), ns_rr_rdata(*rr), ns_rr_rdlen(*rr),
|
||||
name_ctx, origin, buf, buflen);
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* ns_sprintrrf(msg, msglen, name, class, type, ttl, rdata, rdlen,
|
||||
* name_ctx, origin, buf, buflen)
|
||||
* Convert the fields of an RR into presentation format.
|
||||
* return:
|
||||
* Number of characters written to buf, or -1 (check errno).
|
||||
*/
|
||||
int
|
||||
ns_sprintrrf(const u_char *msg, size_t msglen,
|
||||
const char *name, ns_class class, ns_type type,
|
||||
u_long ttl, const u_char *rdata, size_t rdlen,
|
||||
const char *name_ctx, const char *origin,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
const char *obuf = buf;
|
||||
const u_char *edata = rdata + rdlen;
|
||||
int spaced = 0;
|
||||
|
||||
const char *comment;
|
||||
char tmp[100];
|
||||
int len, x;
|
||||
|
||||
/*
|
||||
* Owner.
|
||||
*/
|
||||
if (name_ctx != NULL && ns_samename(name_ctx, name) == 1) {
|
||||
T(addstr("\t\t\t", (size_t)3, &buf, &buflen));
|
||||
} else {
|
||||
len = prune_origin(name, origin);
|
||||
if (*name == '\0') {
|
||||
goto root;
|
||||
} else if (len == 0) {
|
||||
T(addstr("@\t\t\t", (size_t)4, &buf, &buflen));
|
||||
} else {
|
||||
T(addstr(name, (size_t)len, &buf, &buflen));
|
||||
/* Origin not used or not root, and no trailing dot? */
|
||||
if (((origin == NULL || origin[0] == '\0') ||
|
||||
(origin[0] != '.' && origin[1] != '\0' &&
|
||||
name[len] == '\0')) && name[len - 1] != '.') {
|
||||
root:
|
||||
T(addstr(".", (size_t)1, &buf, &buflen));
|
||||
len++;
|
||||
}
|
||||
T(spaced = addtab((size_t)len, 24, spaced, &buf, &buflen));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TTL, Class, Type.
|
||||
*/
|
||||
T(x = ns_format_ttl(ttl, buf, buflen));
|
||||
addlen((size_t)x, &buf, &buflen);
|
||||
len = SPRINTF((tmp, " %s %s", p_class(class), p_type(type)));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
T(spaced = addtab((size_t)(x + len), (size_t)16, spaced, &buf, &buflen));
|
||||
|
||||
/*
|
||||
* RData.
|
||||
*/
|
||||
switch (type) {
|
||||
case ns_t_a:
|
||||
if (rdlen != (size_t)NS_INADDRSZ)
|
||||
goto formerr;
|
||||
(void) inet_ntop(AF_INET, rdata, buf, buflen);
|
||||
addlen(strlen(buf), &buf, &buflen);
|
||||
break;
|
||||
|
||||
case ns_t_cname:
|
||||
case ns_t_mb:
|
||||
case ns_t_mg:
|
||||
case ns_t_mr:
|
||||
case ns_t_ns:
|
||||
case ns_t_ptr:
|
||||
case ns_t_dname:
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
break;
|
||||
|
||||
case ns_t_hinfo:
|
||||
case ns_t_isdn:
|
||||
/* First word. */
|
||||
T(len = charstr(rdata, edata, &buf, &buflen));
|
||||
if (len == 0)
|
||||
goto formerr;
|
||||
rdata += len;
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
|
||||
|
||||
/* Second word, optional in ISDN records. */
|
||||
if (type == ns_t_isdn && rdata == edata)
|
||||
break;
|
||||
|
||||
T(len = charstr(rdata, edata, &buf, &buflen));
|
||||
if (len == 0)
|
||||
goto formerr;
|
||||
rdata += len;
|
||||
break;
|
||||
|
||||
case ns_t_soa: {
|
||||
u_long t;
|
||||
|
||||
/* Server name. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
|
||||
/* Administrator name. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
T(addstr(" (\n", (size_t)3, &buf, &buflen));
|
||||
spaced = 0;
|
||||
|
||||
if ((edata - rdata) != 5*NS_INT32SZ)
|
||||
goto formerr;
|
||||
|
||||
/* Serial number. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen));
|
||||
len = SPRINTF((tmp, "%lu", t));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen));
|
||||
T(addstr("; serial\n", (size_t)9, &buf, &buflen));
|
||||
spaced = 0;
|
||||
|
||||
/* Refresh interval. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen));
|
||||
T(len = ns_format_ttl(t, buf, buflen));
|
||||
addlen((size_t)len, &buf, &buflen);
|
||||
T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen));
|
||||
T(addstr("; refresh\n", (size_t)10, &buf, &buflen));
|
||||
spaced = 0;
|
||||
|
||||
/* Retry interval. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen));
|
||||
T(len = ns_format_ttl(t, buf, buflen));
|
||||
addlen((size_t)len, &buf, &buflen);
|
||||
T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen));
|
||||
T(addstr("; retry\n", (size_t)8, &buf, &buflen));
|
||||
spaced = 0;
|
||||
|
||||
/* Expiry. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen));
|
||||
T(len = ns_format_ttl(t, buf, buflen));
|
||||
addlen((size_t)len, &buf, &buflen);
|
||||
T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen));
|
||||
T(addstr("; expiry\n", (size_t)9, &buf, &buflen));
|
||||
spaced = 0;
|
||||
|
||||
/* Minimum TTL. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen));
|
||||
T(len = ns_format_ttl(t, buf, buflen));
|
||||
addlen((size_t)len, &buf, &buflen);
|
||||
T(addstr(" )", (size_t)2, &buf, &buflen));
|
||||
T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen));
|
||||
T(addstr("; minimum\n", (size_t)10, &buf, &buflen));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_mx:
|
||||
case ns_t_afsdb:
|
||||
case ns_t_rt: {
|
||||
u_int t;
|
||||
|
||||
if (rdlen < (size_t)NS_INT16SZ)
|
||||
goto formerr;
|
||||
|
||||
/* Priority. */
|
||||
t = ns_get16(rdata);
|
||||
rdata += NS_INT16SZ;
|
||||
len = SPRINTF((tmp, "%u ", t));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Target. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_px: {
|
||||
u_int t;
|
||||
|
||||
if (rdlen < (size_t)NS_INT16SZ)
|
||||
goto formerr;
|
||||
|
||||
/* Priority. */
|
||||
t = ns_get16(rdata);
|
||||
rdata += NS_INT16SZ;
|
||||
len = SPRINTF((tmp, "%u ", t));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Name1. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
|
||||
/* Name2. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_x25:
|
||||
T(len = charstr(rdata, edata, &buf, &buflen));
|
||||
if (len == 0)
|
||||
goto formerr;
|
||||
rdata += len;
|
||||
break;
|
||||
|
||||
case ns_t_txt:
|
||||
while (rdata < edata) {
|
||||
T(len = charstr(rdata, edata, &buf, &buflen));
|
||||
if (len == 0)
|
||||
goto formerr;
|
||||
rdata += len;
|
||||
if (rdata < edata)
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
}
|
||||
break;
|
||||
|
||||
case ns_t_nsap: {
|
||||
char t[2+255*3];
|
||||
|
||||
(void) inet_nsap_ntoa((int)rdlen, rdata, t);
|
||||
T(addstr(t, strlen(t), &buf, &buflen));
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_aaaa:
|
||||
if (rdlen != (size_t)NS_IN6ADDRSZ)
|
||||
goto formerr;
|
||||
(void) inet_ntop(AF_INET6, rdata, buf, buflen);
|
||||
addlen(strlen(buf), &buf, &buflen);
|
||||
break;
|
||||
|
||||
case ns_t_loc: {
|
||||
char t[255];
|
||||
|
||||
/* XXX protocol format checking? */
|
||||
(void) loc_ntoa(rdata, t);
|
||||
T(addstr(t, strlen(t), &buf, &buflen));
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_naptr: {
|
||||
u_int order, preference;
|
||||
char t[50];
|
||||
|
||||
if (rdlen < 2U*NS_INT16SZ)
|
||||
goto formerr;
|
||||
|
||||
/* Order, Precedence. */
|
||||
order = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
preference = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
len = SPRINTF((t, "%u %u ", order, preference));
|
||||
T(addstr(t, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Flags. */
|
||||
T(len = charstr(rdata, edata, &buf, &buflen));
|
||||
if (len == 0)
|
||||
goto formerr;
|
||||
rdata += len;
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
|
||||
/* Service. */
|
||||
T(len = charstr(rdata, edata, &buf, &buflen));
|
||||
if (len == 0)
|
||||
goto formerr;
|
||||
rdata += len;
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
|
||||
/* Regexp. */
|
||||
T(len = charstr(rdata, edata, &buf, &buflen));
|
||||
if (len < 0)
|
||||
return (-1);
|
||||
if (len == 0)
|
||||
goto formerr;
|
||||
rdata += len;
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
|
||||
/* Server. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_srv: {
|
||||
u_int priority, weight, port;
|
||||
char t[50];
|
||||
|
||||
if (rdlen < 3U*NS_INT16SZ)
|
||||
goto formerr;
|
||||
|
||||
/* Priority, Weight, Port. */
|
||||
priority = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
weight = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
port = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
len = SPRINTF((t, "%u %u %u ", priority, weight, port));
|
||||
T(addstr(t, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Server. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_minfo:
|
||||
case ns_t_rp:
|
||||
/* Name1. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
|
||||
/* Name2. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
|
||||
break;
|
||||
|
||||
case ns_t_wks: {
|
||||
int n, lcnt;
|
||||
|
||||
if (rdlen < 1U + NS_INT32SZ)
|
||||
goto formerr;
|
||||
|
||||
/* Address. */
|
||||
(void) inet_ntop(AF_INET, rdata, buf, buflen);
|
||||
addlen(strlen(buf), &buf, &buflen);
|
||||
rdata += NS_INADDRSZ;
|
||||
|
||||
/* Protocol. */
|
||||
len = SPRINTF((tmp, " %u ( ", *rdata));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
rdata += NS_INT8SZ;
|
||||
|
||||
/* Bit map. */
|
||||
n = 0;
|
||||
lcnt = 0;
|
||||
while (rdata < edata) {
|
||||
u_int c = *rdata++;
|
||||
do {
|
||||
if (c & 0200) {
|
||||
if (lcnt == 0) {
|
||||
T(addstr("\n\t\t\t\t", (size_t)5,
|
||||
&buf, &buflen));
|
||||
lcnt = 10;
|
||||
spaced = 0;
|
||||
}
|
||||
len = SPRINTF((tmp, "%d ", n));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
lcnt--;
|
||||
}
|
||||
c <<= 1;
|
||||
} while (++n & 07);
|
||||
}
|
||||
T(addstr(")", (size_t)1, &buf, &buflen));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_key: {
|
||||
char base64_key[NS_MD5RSA_MAX_BASE64];
|
||||
u_int keyflags, protocol, algorithm, key_id;
|
||||
const char *leader;
|
||||
int n;
|
||||
|
||||
if (rdlen < 0U + NS_INT16SZ + NS_INT8SZ + NS_INT8SZ)
|
||||
goto formerr;
|
||||
|
||||
/* Key flags, Protocol, Algorithm. */
|
||||
#if !defined(MOZILLA_NECKO_EXCLUDE_CODE) && !defined(_LIBC)
|
||||
key_id = dst_s_dns_key_id(rdata, edata-rdata);
|
||||
#else
|
||||
key_id = 0;
|
||||
#endif
|
||||
keyflags = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
protocol = *rdata++;
|
||||
algorithm = *rdata++;
|
||||
len = SPRINTF((tmp, "0x%04x %u %u",
|
||||
keyflags, protocol, algorithm));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Public key data. */
|
||||
len = b64_ntop(rdata, (size_t)(edata - rdata),
|
||||
base64_key, sizeof base64_key);
|
||||
if (len < 0)
|
||||
goto formerr;
|
||||
if (len > 15) {
|
||||
T(addstr(" (", (size_t)2, &buf, &buflen));
|
||||
leader = "\n\t\t";
|
||||
spaced = 0;
|
||||
} else
|
||||
leader = " ";
|
||||
for (n = 0; n < len; n += 48) {
|
||||
T(addstr(leader, strlen(leader), &buf, &buflen));
|
||||
T(addstr(base64_key + n, (size_t)MIN(len - n, 48),
|
||||
&buf, &buflen));
|
||||
}
|
||||
if (len > 15)
|
||||
T(addstr(" )", (size_t)2, &buf, &buflen));
|
||||
n = SPRINTF((tmp, " ; key_tag= %u", key_id));
|
||||
T(addstr(tmp, (size_t)n, &buf, &buflen));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_sig: {
|
||||
char base64_key[NS_MD5RSA_MAX_BASE64];
|
||||
u_int typ, algorithm, labels, footprint;
|
||||
const char *leader;
|
||||
u_long t;
|
||||
int n;
|
||||
|
||||
if (rdlen < 22U)
|
||||
goto formerr;
|
||||
|
||||
/* Type covered, Algorithm, Label count, Original TTL. */
|
||||
typ = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
algorithm = *rdata++;
|
||||
labels = *rdata++;
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
len = SPRINTF((tmp, "%s %d %d %lu ",
|
||||
p_type((int)typ), algorithm, labels, t));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
if (labels > (u_int)dn_count_labels(name))
|
||||
goto formerr;
|
||||
|
||||
/* Signature expiry. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
len = SPRINTF((tmp, "%s ", p_secstodate(t)));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Time signed. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
len = SPRINTF((tmp, "%s ", p_secstodate(t)));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Signature Footprint. */
|
||||
footprint = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
len = SPRINTF((tmp, "%u ", footprint));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Signer's name. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
|
||||
/* Signature. */
|
||||
len = b64_ntop(rdata, (size_t)(edata - rdata),
|
||||
base64_key, sizeof base64_key);
|
||||
if (len > 15) {
|
||||
T(addstr(" (", (size_t)2, &buf, &buflen));
|
||||
leader = "\n\t\t";
|
||||
spaced = 0;
|
||||
} else
|
||||
leader = " ";
|
||||
if (len < 0)
|
||||
goto formerr;
|
||||
for (n = 0; n < len; n += 48) {
|
||||
T(addstr(leader, strlen(leader), &buf, &buflen));
|
||||
T(addstr(base64_key + n, (size_t)MIN(len - n, 48),
|
||||
&buf, &buflen));
|
||||
}
|
||||
if (len > 15)
|
||||
T(addstr(" )", (size_t)2, &buf, &buflen));
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_nxt: {
|
||||
int n, c;
|
||||
|
||||
/* Next domain name. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
|
||||
/* Type bit map. */
|
||||
n = edata - rdata;
|
||||
for (c = 0; c < n*8; c++)
|
||||
if (NS_NXT_BIT_ISSET(c, rdata)) {
|
||||
len = SPRINTF((tmp, " %s", p_type(c)));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_cert: {
|
||||
u_int c_type, key_tag, alg;
|
||||
int n;
|
||||
unsigned int siz;
|
||||
char base64_cert[8192], tmp1[40];
|
||||
const char *leader;
|
||||
|
||||
c_type = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
key_tag = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
alg = (u_int) *rdata++;
|
||||
|
||||
len = SPRINTF((tmp1, "%d %d %d ", c_type, key_tag, alg));
|
||||
T(addstr(tmp1, (size_t)len, &buf, &buflen));
|
||||
siz = (edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */
|
||||
if (siz > sizeof(base64_cert) * 3/4) {
|
||||
const char *str = "record too long to print";
|
||||
T(addstr(str, strlen(str), &buf, &buflen));
|
||||
}
|
||||
else {
|
||||
len = b64_ntop(rdata, (size_t)(edata-rdata),
|
||||
base64_cert, siz);
|
||||
|
||||
if (len < 0)
|
||||
goto formerr;
|
||||
else if (len > 15) {
|
||||
T(addstr(" (", (size_t)2, &buf, &buflen));
|
||||
leader = "\n\t\t";
|
||||
spaced = 0;
|
||||
}
|
||||
else
|
||||
leader = " ";
|
||||
|
||||
for (n = 0; n < len; n += 48) {
|
||||
T(addstr(leader, strlen(leader),
|
||||
&buf, &buflen));
|
||||
T(addstr(base64_cert + n, (size_t)MIN(len - n, 48),
|
||||
&buf, &buflen));
|
||||
}
|
||||
if (len > 15)
|
||||
T(addstr(" )", (size_t)2, &buf, &buflen));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_tkey: {
|
||||
/* KJD - need to complete this */
|
||||
u_long t;
|
||||
int mode, err, keysize;
|
||||
|
||||
/* Algorithm name. */
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
|
||||
/* Inception. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
len = SPRINTF((tmp, "%s ", p_secstodate(t)));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Experation. */
|
||||
t = ns_get32(rdata); rdata += NS_INT32SZ;
|
||||
len = SPRINTF((tmp, "%s ", p_secstodate(t)));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* Mode , Error, Key Size. */
|
||||
/* Priority, Weight, Port. */
|
||||
mode = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
err = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
keysize = ns_get16(rdata); rdata += NS_INT16SZ;
|
||||
len = SPRINTF((tmp, "%u %u %u ", mode, err, keysize));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
|
||||
/* XXX need to dump key, print otherdata length & other data */
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_tsig: {
|
||||
/* BEW - need to complete this */
|
||||
int n;
|
||||
|
||||
T(len = addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
rdata += 8; /* time */
|
||||
n = ns_get16(rdata); rdata += INT16SZ;
|
||||
rdata += n; /* sig */
|
||||
n = ns_get16(rdata); rdata += INT16SZ; /* original id */
|
||||
sprintf(buf, "%d", ns_get16(rdata));
|
||||
rdata += INT16SZ;
|
||||
addlen(strlen(buf), &buf, &buflen);
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_a6: {
|
||||
struct in6_addr a;
|
||||
int pbyte, pbit;
|
||||
|
||||
/* prefix length */
|
||||
if (rdlen == 0U) goto formerr;
|
||||
len = SPRINTF((tmp, "%d ", *rdata));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
pbit = *rdata;
|
||||
if (pbit > 128) goto formerr;
|
||||
pbyte = (pbit & ~7) / 8;
|
||||
rdata++;
|
||||
|
||||
/* address suffix: provided only when prefix len != 128 */
|
||||
if (pbit < 128) {
|
||||
if (rdata + pbyte >= edata) goto formerr;
|
||||
memset(&a, 0, sizeof(a));
|
||||
memcpy(&a.s6_addr[pbyte], rdata, sizeof(a) - pbyte);
|
||||
(void) inet_ntop(AF_INET6, &a, buf, buflen);
|
||||
addlen(strlen(buf), &buf, &buflen);
|
||||
rdata += sizeof(a) - pbyte;
|
||||
}
|
||||
|
||||
/* prefix name: provided only when prefix len > 0 */
|
||||
if (pbit == 0)
|
||||
break;
|
||||
if (rdata >= edata) goto formerr;
|
||||
T(addstr(" ", (size_t)1, &buf, &buflen));
|
||||
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ns_t_opt: {
|
||||
len = SPRINTF((tmp, "%u bytes", class));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
comment = "unknown RR type";
|
||||
goto hexify;
|
||||
}
|
||||
return (buf - obuf);
|
||||
formerr:
|
||||
comment = "RR format error";
|
||||
hexify: {
|
||||
int n, m;
|
||||
char *p;
|
||||
|
||||
len = SPRINTF((tmp, "\\# %tu%s\t; %s", edata - rdata,
|
||||
rdlen != 0 ? " (" : "", comment));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
while (rdata < edata) {
|
||||
p = tmp;
|
||||
p += SPRINTF((p, "\n\t"));
|
||||
spaced = 0;
|
||||
n = MIN(16, edata - rdata);
|
||||
for (m = 0; m < n; m++)
|
||||
p += SPRINTF((p, "%02x ", rdata[m]));
|
||||
T(addstr(tmp, (size_t)(p - tmp), &buf, &buflen));
|
||||
if (n < 16) {
|
||||
T(addstr(")", (size_t)1, &buf, &buflen));
|
||||
T(addtab((size_t)(p - tmp + 1), (size_t)48, spaced, &buf, &buflen));
|
||||
}
|
||||
p = tmp;
|
||||
p += SPRINTF((p, "; "));
|
||||
for (m = 0; m < n; m++)
|
||||
*p++ = (isascii(rdata[m]) && isprint(rdata[m]))
|
||||
? rdata[m]
|
||||
: '.';
|
||||
T(addstr(tmp, (size_t)(p - tmp), &buf, &buflen));
|
||||
rdata += n;
|
||||
}
|
||||
return (buf - obuf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Private. */
|
||||
|
||||
/*
|
||||
* size_t
|
||||
* prune_origin(name, origin)
|
||||
* Find out if the name is at or under the current origin.
|
||||
* return:
|
||||
* Number of characters in name before start of origin,
|
||||
* or length of name if origin does not match.
|
||||
* notes:
|
||||
* This function should share code with samedomain().
|
||||
*/
|
||||
static size_t
|
||||
prune_origin(const char *name, const char *origin) {
|
||||
const char *oname = name;
|
||||
|
||||
while (*name != '\0') {
|
||||
if (origin != NULL && ns_samename(name, origin) == 1)
|
||||
return (name - oname - (name > oname));
|
||||
while (*name != '\0') {
|
||||
if (*name == '\\') {
|
||||
name++;
|
||||
/* XXX need to handle \nnn form. */
|
||||
if (*name == '\0')
|
||||
break;
|
||||
} else if (*name == '.') {
|
||||
name++;
|
||||
break;
|
||||
}
|
||||
name++;
|
||||
}
|
||||
}
|
||||
return (name - oname);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* charstr(rdata, edata, buf, buflen)
|
||||
* Format a <character-string> into the presentation buffer.
|
||||
* return:
|
||||
* Number of rdata octets consumed
|
||||
* 0 for protocol format error
|
||||
* -1 for output buffer error
|
||||
* side effects:
|
||||
* buffer is advanced on success.
|
||||
*/
|
||||
static int
|
||||
charstr(const u_char *rdata, const u_char *edata, char **buf, size_t *buflen) {
|
||||
const u_char *odata = rdata;
|
||||
size_t save_buflen = *buflen;
|
||||
char *save_buf = *buf;
|
||||
|
||||
if (addstr("\"", (size_t)1, buf, buflen) < 0)
|
||||
goto enospc;
|
||||
if (rdata < edata) {
|
||||
int n = *rdata;
|
||||
|
||||
if (rdata + 1 + n <= edata) {
|
||||
rdata++;
|
||||
while (n-- > 0) {
|
||||
if (strchr("\n\"\\", *rdata) != NULL)
|
||||
if (addstr("\\", (size_t)1, buf, buflen) < 0)
|
||||
goto enospc;
|
||||
if (addstr((const char *)rdata, (size_t)1,
|
||||
buf, buflen) < 0)
|
||||
goto enospc;
|
||||
rdata++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addstr("\"", (size_t)1, buf, buflen) < 0)
|
||||
goto enospc;
|
||||
return (rdata - odata);
|
||||
enospc:
|
||||
errno = ENOSPC;
|
||||
*buf = save_buf;
|
||||
*buflen = save_buflen;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
addname(const u_char *msg, size_t msglen,
|
||||
const u_char **pp, const char *origin,
|
||||
char **buf, size_t *buflen)
|
||||
{
|
||||
size_t newlen, save_buflen = *buflen;
|
||||
char *save_buf = *buf;
|
||||
int n;
|
||||
|
||||
n = dn_expand(msg, msg + msglen, *pp, *buf, (int)*buflen);
|
||||
if (n < 0)
|
||||
goto enospc; /* Guess. */
|
||||
newlen = prune_origin(*buf, origin);
|
||||
if (**buf == '\0') {
|
||||
goto root;
|
||||
} else if (newlen == 0U) {
|
||||
/* Use "@" instead of name. */
|
||||
if (newlen + 2 > *buflen)
|
||||
goto enospc; /* No room for "@\0". */
|
||||
(*buf)[newlen++] = '@';
|
||||
(*buf)[newlen] = '\0';
|
||||
} else {
|
||||
if (((origin == NULL || origin[0] == '\0') ||
|
||||
(origin[0] != '.' && origin[1] != '\0' &&
|
||||
(*buf)[newlen] == '\0')) && (*buf)[newlen - 1] != '.') {
|
||||
/* No trailing dot. */
|
||||
root:
|
||||
if (newlen + 2 > *buflen)
|
||||
goto enospc; /* No room for ".\0". */
|
||||
(*buf)[newlen++] = '.';
|
||||
(*buf)[newlen] = '\0';
|
||||
}
|
||||
}
|
||||
*pp += n;
|
||||
addlen(newlen, buf, buflen);
|
||||
**buf = '\0';
|
||||
return (newlen);
|
||||
enospc:
|
||||
errno = ENOSPC;
|
||||
*buf = save_buf;
|
||||
*buflen = save_buflen;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
addlen(size_t len, char **buf, size_t *buflen) {
|
||||
assert(len <= *buflen);
|
||||
*buf += len;
|
||||
*buflen -= len;
|
||||
}
|
||||
|
||||
static int
|
||||
addstr(const char *src, size_t len, char **buf, size_t *buflen) {
|
||||
if (len >= *buflen) {
|
||||
errno = ENOSPC;
|
||||
return (-1);
|
||||
}
|
||||
memcpy(*buf, src, len);
|
||||
addlen(len, buf, buflen);
|
||||
**buf = '\0';
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
addtab(size_t len, size_t target, int spaced, char **buf, size_t *buflen) {
|
||||
size_t save_buflen = *buflen;
|
||||
char *save_buf = *buf;
|
||||
int t;
|
||||
|
||||
if (spaced || len >= target - 1) {
|
||||
T(addstr(" ", (size_t)2, buf, buflen));
|
||||
spaced = 1;
|
||||
} else {
|
||||
for (t = (target - len - 1) / 8; t >= 0; t--)
|
||||
if (addstr("\t", (size_t)1, buf, buflen) < 0) {
|
||||
*buflen = save_buflen;
|
||||
*buf = save_buf;
|
||||
return (-1);
|
||||
}
|
||||
spaced = 0;
|
||||
}
|
||||
return (spaced);
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
/* $NetBSD: ns_samedomain.c,v 1.2 2004/05/20 20:35:05 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1995,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#define ANDROID_CHANGES 1
|
||||
#define MOZILLA_NECKO_EXCLUDE_CODE 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#ifdef notdef
|
||||
static const char rcsid[] = "Id: ns_samedomain.c,v 1.1.2.2.4.2 2004/03/16 12:34:17 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: ns_samedomain.c,v 1.2 2004/05/20 20:35:05 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "arpa_nameser.h"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef MOZILLA_NECKO_EXCLUDE_CODE
|
||||
#ifndef _LIBC
|
||||
/*
|
||||
* int
|
||||
* ns_samedomain(a, b)
|
||||
* Check whether a name belongs to a domain.
|
||||
* Inputs:
|
||||
* a - the domain whose ancestory is being verified
|
||||
* b - the potential ancestor we're checking against
|
||||
* Return:
|
||||
* boolean - is a at or below b?
|
||||
* Notes:
|
||||
* Trailing dots are first removed from name and domain.
|
||||
* Always compare complete subdomains, not only whether the
|
||||
* domain name is the trailing string of the given name.
|
||||
*
|
||||
* "host.foobar.top" lies in "foobar.top" and in "top" and in ""
|
||||
* but NOT in "bar.top"
|
||||
*/
|
||||
|
||||
int
|
||||
ns_samedomain(const char *a, const char *b) {
|
||||
size_t la, lb;
|
||||
int diff, i, escaped;
|
||||
const char *cp;
|
||||
|
||||
la = strlen(a);
|
||||
lb = strlen(b);
|
||||
|
||||
/* Ignore a trailing label separator (i.e. an unescaped dot) in 'a'. */
|
||||
if (la != 0U && a[la - 1] == '.') {
|
||||
escaped = 0;
|
||||
/* Note this loop doesn't get executed if la==1. */
|
||||
for (i = la - 2; i >= 0; i--)
|
||||
if (a[i] == '\\') {
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else
|
||||
escaped = 1;
|
||||
} else
|
||||
break;
|
||||
if (!escaped)
|
||||
la--;
|
||||
}
|
||||
|
||||
/* Ignore a trailing label separator (i.e. an unescaped dot) in 'b'. */
|
||||
if (lb != 0U && b[lb - 1] == '.') {
|
||||
escaped = 0;
|
||||
/* note this loop doesn't get executed if lb==1 */
|
||||
for (i = lb - 2; i >= 0; i--)
|
||||
if (b[i] == '\\') {
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else
|
||||
escaped = 1;
|
||||
} else
|
||||
break;
|
||||
if (!escaped)
|
||||
lb--;
|
||||
}
|
||||
|
||||
/* lb == 0 means 'b' is the root domain, so 'a' must be in 'b'. */
|
||||
if (lb == 0U)
|
||||
return (1);
|
||||
|
||||
/* 'b' longer than 'a' means 'a' can't be in 'b'. */
|
||||
if (lb > la)
|
||||
return (0);
|
||||
|
||||
/* 'a' and 'b' being equal at this point indicates sameness. */
|
||||
if (lb == la)
|
||||
return (strncasecmp(a, b, lb) == 0);
|
||||
|
||||
/* Ok, we know la > lb. */
|
||||
|
||||
diff = la - lb;
|
||||
|
||||
/*
|
||||
* If 'a' is only 1 character longer than 'b', then it can't be
|
||||
* a subdomain of 'b' (because of the need for the '.' label
|
||||
* separator).
|
||||
*/
|
||||
if (diff < 2)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* If the character before the last 'lb' characters of 'b'
|
||||
* isn't '.', then it can't be a match (this lets us avoid
|
||||
* having "foobar.com" match "bar.com").
|
||||
*/
|
||||
if (a[diff - 1] != '.')
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* We're not sure about that '.', however. It could be escaped
|
||||
* and thus not a really a label separator.
|
||||
*/
|
||||
escaped = 0;
|
||||
for (i = diff - 2; i >= 0; i--)
|
||||
if (a[i] == '\\') {
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else
|
||||
escaped = 1;
|
||||
} else
|
||||
break;
|
||||
if (escaped)
|
||||
return (0);
|
||||
|
||||
/* Now compare aligned trailing substring. */
|
||||
cp = a + diff;
|
||||
return (strncasecmp(cp, b, lb) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* ns_subdomain(a, b)
|
||||
* is "a" a subdomain of "b"?
|
||||
*/
|
||||
int
|
||||
ns_subdomain(const char *a, const char *b) {
|
||||
return (ns_samename(a, b) != 1 && ns_samedomain(a, b));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* int
|
||||
* ns_makecanon(src, dst, dstsize)
|
||||
* make a canonical copy of domain name "src"
|
||||
* notes:
|
||||
* foo -> foo.
|
||||
* foo. -> foo.
|
||||
* foo.. -> foo.
|
||||
* foo\. -> foo\..
|
||||
* foo\\. -> foo\\.
|
||||
*/
|
||||
|
||||
int
|
||||
ns_makecanon(const char *src, char *dst, size_t dstsize) {
|
||||
size_t n = strlen(src);
|
||||
|
||||
if (n + sizeof "." > dstsize) { /* Note: sizeof == 2 */
|
||||
errno = EMSGSIZE;
|
||||
return (-1);
|
||||
}
|
||||
strcpy(dst, src);
|
||||
while (n >= 1U && dst[n - 1] == '.') /* Ends in "." */
|
||||
if (n >= 2U && dst[n - 2] == '\\' && /* Ends in "\." */
|
||||
(n < 3U || dst[n - 3] != '\\')) /* But not "\\." */
|
||||
break;
|
||||
else
|
||||
dst[--n] = '\0';
|
||||
dst[n++] = '.';
|
||||
dst[n] = '\0';
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* ns_samename(a, b)
|
||||
* determine whether domain name "a" is the same as domain name "b"
|
||||
* return:
|
||||
* -1 on error
|
||||
* 0 if names differ
|
||||
* 1 if names are the same
|
||||
*/
|
||||
|
||||
int
|
||||
ns_samename(const char *a, const char *b) {
|
||||
char ta[NS_MAXDNAME], tb[NS_MAXDNAME];
|
||||
|
||||
if (ns_makecanon(a, ta, sizeof ta) < 0 ||
|
||||
ns_makecanon(b, tb, sizeof tb) < 0)
|
||||
return (-1);
|
||||
if (strcasecmp(ta, tb) == 0)
|
||||
return (1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
/* $NetBSD: ns_ttl.c,v 1.2 2004/05/20 20:35:05 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This version of this file is derived from Android 2.3 "Gingerbread",
|
||||
* which contains uncredited changes by Android/Google developers. It has
|
||||
* been modified in 2011 for use in the Android build of Mozilla Firefox by
|
||||
* Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
|
||||
* and Steve Workman <sjhworkman@gmail.com>).
|
||||
* These changes are offered under the same license as the original NetBSD
|
||||
* file, whose copyright and license are unchanged above.
|
||||
*/
|
||||
|
||||
#define ANDROID_CHANGES 1
|
||||
#define MOZILLA_NECKO_EXCLUDE_CODE 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#ifdef notdef
|
||||
static const char rcsid[] = "Id: ns_ttl.c,v 1.1.206.1 2004/03/09 08:33:45 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: ns_ttl.c,v 1.2 2004/05/20 20:35:05 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Import. */
|
||||
|
||||
#include "arpa_nameser.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef SPRINTF_CHAR
|
||||
# define SPRINTF(x) strlen(sprintf/**/x)
|
||||
#else
|
||||
# define SPRINTF(x) ((size_t)sprintf x)
|
||||
#endif
|
||||
|
||||
/* Forward. */
|
||||
|
||||
static int fmt1(int t, char s, char **buf, size_t *buflen);
|
||||
|
||||
/* Macros. */
|
||||
|
||||
#define T(x) do { if ((x) < 0) return (-1); } while(0)
|
||||
|
||||
/* Public. */
|
||||
|
||||
int
|
||||
ns_format_ttl(u_long src, char *dst, size_t dstlen) {
|
||||
char *odst = dst;
|
||||
int secs, mins, hours, days, weeks, x;
|
||||
char *p;
|
||||
|
||||
secs = src % 60; src /= 60;
|
||||
mins = src % 60; src /= 60;
|
||||
hours = src % 24; src /= 24;
|
||||
days = src % 7; src /= 7;
|
||||
weeks = src; src = 0;
|
||||
|
||||
x = 0;
|
||||
if (weeks) {
|
||||
T(fmt1(weeks, 'W', &dst, &dstlen));
|
||||
x++;
|
||||
}
|
||||
if (days) {
|
||||
T(fmt1(days, 'D', &dst, &dstlen));
|
||||
x++;
|
||||
}
|
||||
if (hours) {
|
||||
T(fmt1(hours, 'H', &dst, &dstlen));
|
||||
x++;
|
||||
}
|
||||
if (mins) {
|
||||
T(fmt1(mins, 'M', &dst, &dstlen));
|
||||
x++;
|
||||
}
|
||||
if (secs || !(weeks || days || hours || mins)) {
|
||||
T(fmt1(secs, 'S', &dst, &dstlen));
|
||||
x++;
|
||||
}
|
||||
|
||||
if (x > 1) {
|
||||
int ch;
|
||||
|
||||
for (p = odst; (ch = *p) != '\0'; p++)
|
||||
if (isascii(ch) && isupper(ch))
|
||||
*p = tolower(ch);
|
||||
}
|
||||
|
||||
return (dst - odst);
|
||||
}
|
||||
|
||||
#ifndef MOZILLA_NECKO_EXCLUDE_CODE
|
||||
#ifndef _LIBC
|
||||
int
|
||||
ns_parse_ttl(const char *src, u_long *dst) {
|
||||
u_long ttl, tmp;
|
||||
int ch, digits, dirty;
|
||||
|
||||
ttl = 0;
|
||||
tmp = 0;
|
||||
digits = 0;
|
||||
dirty = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
if (!isascii(ch) || !isprint(ch))
|
||||
goto einval;
|
||||
if (isdigit(ch)) {
|
||||
tmp *= 10;
|
||||
tmp += (ch - '0');
|
||||
digits++;
|
||||
continue;
|
||||
}
|
||||
if (digits == 0)
|
||||
goto einval;
|
||||
if (islower(ch))
|
||||
ch = toupper(ch);
|
||||
switch (ch) {
|
||||
case 'W': tmp *= 7; /*FALLTHROUGH*/
|
||||
case 'D': tmp *= 24; /*FALLTHROUGH*/
|
||||
case 'H': tmp *= 60; /*FALLTHROUGH*/
|
||||
case 'M': tmp *= 60; /*FALLTHROUGH*/
|
||||
case 'S': break;
|
||||
default: goto einval;
|
||||
}
|
||||
ttl += tmp;
|
||||
tmp = 0;
|
||||
digits = 0;
|
||||
dirty = 1;
|
||||
}
|
||||
if (digits > 0) {
|
||||
if (dirty)
|
||||
goto einval;
|
||||
else
|
||||
ttl += tmp;
|
||||
}
|
||||
*dst = ttl;
|
||||
return (0);
|
||||
|
||||
einval:
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Private. */
|
||||
|
||||
static int
|
||||
fmt1(int t, char s, char **buf, size_t *buflen) {
|
||||
char tmp[50];
|
||||
size_t len;
|
||||
|
||||
len = SPRINTF((tmp, "%d%c", t, s));
|
||||
if (len + 1 > *buflen)
|
||||
return (-1);
|
||||
strcpy(*buf, tmp);
|
||||
*buf += len;
|
||||
*buflen -= len;
|
||||
return (0);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user