1/* 2 * Copyright (c) 2006,2011,2014 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23#ifndef _SEC_XDR_H 24#define _SEC_XDR_H 25 26#include <rpc/types.h> 27#include <rpc/xdr.h> 28#include <stdint.h> 29 30__BEGIN_DECLS 31 32extern bool_t sec_xdr_bytes(XDR *, uint8_t **, unsigned int *, unsigned int); 33extern bool_t sec_xdr_array(XDR *, uint8_t **, unsigned int *, unsigned int, unsigned int, xdrproc_t); 34extern bool_t sec_xdr_charp(XDR *, char **, u_int); 35extern bool_t sec_xdr_reference(XDR *xdrs, uint8_t **pp, u_int size, xdrproc_t proc); 36extern bool_t sec_xdr_pointer(XDR *xdrs, uint8_t **objpp, u_int obj_size, xdrproc_t xdr_obj); 37 38bool_t sec_mem_alloc(XDR *xdr, u_int bsize, uint8_t **data); 39void sec_mem_free(XDR *xdr, void *ptr, u_int bsize); 40 41void sec_xdrmem_create(XDR *xdrs, char *addr, u_int size, enum xdr_op op); 42 43typedef struct sec_xdr_arena_allocator { 44 uint32_t magic; 45 uint8_t *offset; 46 uint8_t *data; 47 uint8_t *end; 48} sec_xdr_arena_allocator_t; 49 50#define xdr_arena_magic 0xAEA1 51#define xdr_size_magic 0xDEAD 52 53void sec_xdr_arena_init_size_alloc(sec_xdr_arena_allocator_t *arena, XDR *xdr); 54bool_t sec_xdr_arena_init(sec_xdr_arena_allocator_t *arena, XDR *xdr, 55 size_t in_length, uint8_t *in_data); 56void sec_xdr_arena_free(sec_xdr_arena_allocator_t *alloc, void *ptr, size_t bsize); 57void *sec_xdr_arena_data(sec_xdr_arena_allocator_t *alloc); 58sec_xdr_arena_allocator_t *sec_xdr_arena_allocator(XDR *xdr); 59bool_t sec_xdr_arena_size_allocator(XDR *xdr); 60 61bool_t copyin(void * data, xdrproc_t proc, void ** copy, u_int * size); 62bool_t copyout(const void * copy, u_int size, xdrproc_t proc, void ** data, u_int *length); 63bool_t copyout_chunked(const void * copy, u_int size, xdrproc_t proc, void ** data); 64 65u_int sec_xdr_sizeof_in(xdrproc_t func, void * data); 66u_int sec_xdr_sizeof_out(const void * copy, u_int size, xdrproc_t func, void ** data); 67 68__END_DECLS 69 70#endif /* !_SEC_XDR_H */ 71