2 * Copyright (c) 2003-2004 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
28 // transwalkers - server side transition data walking support
30 // These are data walker operators for securely marshaling and unmarshaling
31 // data structures across IPC. They are also in charge of fixing byte order
32 // inconsistencies between server and clients.
34 #include <transwalkers.h>
37 using LowLevelMemoryUtilities::increment
;
38 using LowLevelMemoryUtilities::difference
;
43 return Server::process().byteFlipped();
48 // CheckingRelocateWalkers
50 CheckingReconstituteWalker::CheckingReconstituteWalker(void *ptr
, void *base
, size_t size
, bool flip
)
51 : mBase(base
), mFlip(flip
)
54 Flippers::flip(mBase
); // came in reversed; fix for base use
55 mOffset
= difference(ptr
, mBase
);
56 mLimit
= increment(mBase
, size
);
63 void relocate(Context
&context
, void *base
, Context::Attr
*attrs
, uint32 attrSize
)
66 CheckingReconstituteWalker
relocator(attrs
, base
, attrSize
, flipClient());
67 context
.ContextAttributes
= attrs
; // fix context->attr vector link
68 for (uint32 n
= 0; n
< context
.attributesInUse(); n
++)
69 walk(relocator
, context
[n
]);
74 // Outbound flipping support
76 FlipWalker::~FlipWalker()
78 for (set
<Flipper
>::const_iterator it
= mFlips
.begin(); it
!= mFlips
.end(); it
++)
82 void FlipWalker::doFlips(bool active
)
85 secdebug("flipwalkers", "starting outbound flips");
86 for (set
<Flipper
>::const_iterator it
= mFlips
.begin(); it
!= mFlips
.end(); it
++)
88 secdebug("flipwalkers", "outbound flips done");