2005-08-03 00:12:31 +04:00
/*
Unix SMB / CIFS implementation .
TDR definitions
Copyright ( C ) Jelmer Vernooij 2005
2011-02-27 20:42:00 +03:00
2005-08-03 00:12:31 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2005-08-03 00:12:31 +04:00
( at your option ) any later version .
2011-02-27 20:42:00 +03:00
2005-08-03 00:12:31 +04:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2011-02-27 20:42:00 +03:00
2005-08-03 00:12:31 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-08-03 00:12:31 +04:00
*/
2006-03-17 00:36:36 +03:00
# ifndef __TDR_H__
# define __TDR_H__
2007-08-31 03:15:12 +04:00
# include <talloc.h>
2008-10-24 02:06:35 +04:00
# include "../lib/util/charset/charset.h"
2006-03-17 00:36:36 +03:00
2005-08-21 17:19:36 +04:00
# define TDR_BIG_ENDIAN 0x01
# define TDR_ALIGN2 0x02
# define TDR_ALIGN4 0x04
# define TDR_ALIGN8 0x08
# define TDR_REMAINING 0x10
2005-08-03 00:12:31 +04:00
struct tdr_pull {
2005-09-02 18:05:28 +04:00
DATA_BLOB data ;
2005-08-03 00:12:31 +04:00
uint32_t offset ;
int flags ;
} ;
struct tdr_push {
2005-09-02 18:05:28 +04:00
DATA_BLOB data ;
2005-08-03 00:12:31 +04:00
int flags ;
} ;
struct tdr_print {
int level ;
void ( * print ) ( struct tdr_print * , const char * , . . . ) ;
2005-08-21 17:19:36 +04:00
int flags ;
2005-08-03 00:12:31 +04:00
} ;
# define TDR_CHECK(call) do { NTSTATUS _status; \
_status = call ; \
if ( ! NT_STATUS_IS_OK ( _status ) ) \
return _status ; \
} while ( 0 )
2005-09-05 00:17:21 +04:00
# define TDR_ALLOC(ctx, s, n) do { \
2009-10-02 03:25:13 +04:00
( s ) = talloc_array_ptrtype ( ctx , ( s ) , n ) ; \
2005-08-03 00:12:31 +04:00
if ( ( n ) & & ! ( s ) ) return NT_STATUS_NO_MEMORY ; \
} while ( 0 )
2005-09-04 17:13:47 +04:00
2005-09-04 21:25:04 +04:00
typedef NTSTATUS ( * tdr_push_fn_t ) ( struct tdr_push * , const void * ) ;
2005-09-05 00:17:21 +04:00
typedef NTSTATUS ( * tdr_pull_fn_t ) ( struct tdr_pull * , TALLOC_CTX * , void * ) ;
2005-12-28 01:51:30 +03:00
2011-02-27 20:42:00 +03:00
NTSTATUS tdr_push_expand ( struct tdr_push * tdr , uint32_t size ) ;
NTSTATUS tdr_pull_uint8 ( struct tdr_pull * tdr , TALLOC_CTX * ctx , uint8_t * v ) ;
NTSTATUS tdr_push_uint8 ( struct tdr_push * tdr , const uint8_t * v ) ;
NTSTATUS tdr_print_uint8 ( struct tdr_print * tdr , const char * name , uint8_t * v ) ;
NTSTATUS tdr_pull_uint16 ( struct tdr_pull * tdr , TALLOC_CTX * ctx , uint16_t * v ) ;
NTSTATUS tdr_pull_uint1632 ( struct tdr_pull * tdr , TALLOC_CTX * ctx , uint16_t * v ) ;
NTSTATUS tdr_push_uint16 ( struct tdr_push * tdr , const uint16_t * v ) ;
NTSTATUS tdr_push_uint1632 ( struct tdr_push * tdr , const uint16_t * v ) ;
NTSTATUS tdr_print_uint16 ( struct tdr_print * tdr , const char * name , uint16_t * v ) ;
NTSTATUS tdr_pull_uint32 ( struct tdr_pull * tdr , TALLOC_CTX * ctx , uint32_t * v ) ;
NTSTATUS tdr_push_uint32 ( struct tdr_push * tdr , const uint32_t * v ) ;
NTSTATUS tdr_print_uint32 ( struct tdr_print * tdr , const char * name , uint32_t * v ) ;
NTSTATUS tdr_pull_charset ( struct tdr_pull * tdr , TALLOC_CTX * ctx , const char * * v , uint32_t length , uint32_t el_size , charset_t chset ) ;
NTSTATUS tdr_push_charset ( struct tdr_push * tdr , const char * * v , uint32_t length , uint32_t el_size , charset_t chset ) ;
NTSTATUS tdr_print_charset ( struct tdr_print * tdr , const char * name , const char * * v , uint32_t length , uint32_t el_size , charset_t chset ) ;
NTSTATUS tdr_pull_hyper ( struct tdr_pull * tdr , TALLOC_CTX * ctx , uint64_t * v ) ;
NTSTATUS tdr_push_hyper ( struct tdr_push * tdr , uint64_t * v ) ;
NTSTATUS tdr_push_NTTIME ( struct tdr_push * tdr , NTTIME * t ) ;
NTSTATUS tdr_pull_NTTIME ( struct tdr_pull * tdr , TALLOC_CTX * ctx , NTTIME * t ) ;
NTSTATUS tdr_print_NTTIME ( struct tdr_print * tdr , const char * name , NTTIME * t ) ;
NTSTATUS tdr_push_time_t ( struct tdr_push * tdr , time_t * t ) ;
NTSTATUS tdr_pull_time_t ( struct tdr_pull * tdr , TALLOC_CTX * ctx , time_t * t ) ;
NTSTATUS tdr_print_time_t ( struct tdr_print * tdr , const char * name , time_t * t ) ;
NTSTATUS tdr_print_DATA_BLOB ( struct tdr_print * tdr , const char * name , DATA_BLOB * r ) ;
NTSTATUS tdr_push_DATA_BLOB ( struct tdr_push * tdr , DATA_BLOB * blob ) ;
NTSTATUS tdr_pull_DATA_BLOB ( struct tdr_pull * tdr , TALLOC_CTX * ctx , DATA_BLOB * blob ) ;
struct tdr_push * tdr_push_init ( TALLOC_CTX * mem_ctx ) ;
struct tdr_pull * tdr_pull_init ( TALLOC_CTX * mem_ctx ) ;
NTSTATUS tdr_push_to_fd ( int fd , tdr_push_fn_t push_fn , const void * p ) ;
2011-03-16 22:32:53 +03:00
void tdr_print_debug_helper ( struct tdr_print * tdr , const char * format , . . . ) PRINTF_ATTRIBUTE ( 2 , 3 ) ;
2006-03-17 00:36:36 +03:00
# endif /* __TDR_H__ */