18ac37778c77e085331bf933482bafab40f1a389
[vlendec/samba-autobuild/.git] / source3 / rpc_parse / parse_rpc.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  Copyright (C) Jeremy Allison                    1999.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #include "includes.h"
25
26 #undef DBGC_CLASS
27 #define DBGC_CLASS DBGC_RPC_PARSE
28
29 /*******************************************************************
30 interface/version dce/rpc pipe identification
31 ********************************************************************/
32
33 #define TRANS_SYNT_V2                       \
34 {                                           \
35         {                                   \
36                 0x8a885d04, 0x1ceb, 0x11c9, \
37                 { 0x9f, 0xe8, 0x08, 0x00,   \
38                 0x2b, 0x10, 0x48, 0x60 }    \
39         }, 0x02                             \
40 }
41
42 #define SYNT_NETLOGON_V2                    \
43 {                                           \
44         {                                   \
45                 0x8a885d04, 0x1ceb, 0x11c9, \
46                 { 0x9f, 0xe8, 0x08, 0x00,   \
47                 0x2b, 0x10, 0x48, 0x60 }    \
48         }, 0x02                             \
49 }
50
51 #define SYNT_WKSSVC_V1                      \
52 {                                           \
53         {                                   \
54                 0x6bffd098, 0xa112, 0x3610, \
55                 { 0x98, 0x33, 0x46, 0xc3,   \
56                 0xf8, 0x7e, 0x34, 0x5a }    \
57         }, 0x01                             \
58 }
59
60 #define SYNT_SRVSVC_V3                      \
61 {                                           \
62         {                                   \
63                 0x4b324fc8, 0x1670, 0x01d3, \
64                 { 0x12, 0x78, 0x5a, 0x47,   \
65                 0xbf, 0x6e, 0xe1, 0x88 }    \
66         }, 0x03                             \
67 }
68
69 #define SYNT_LSARPC_V0                      \
70 {                                           \
71         {                                   \
72                 0x12345778, 0x1234, 0xabcd, \
73                 { 0xef, 0x00, 0x01, 0x23,   \
74                 0x45, 0x67, 0x89, 0xab }    \
75         }, 0x00                             \
76 }
77
78 #define SYNT_LSARPC_V0_DS                \
79 {                                           \
80         {                                   \
81                 0x3919286a, 0xb10c, 0x11d0, \
82                 { 0x9b, 0xa8, 0x00, 0xc0,   \
83                 0x4f, 0xd9, 0x2e, 0xf5 }    \
84         }, 0x00                             \
85 }
86
87 #define SYNT_SAMR_V1                        \
88 {                                           \
89         {                                   \
90                 0x12345778, 0x1234, 0xabcd, \
91                 { 0xef, 0x00, 0x01, 0x23,   \
92                 0x45, 0x67, 0x89, 0xac }    \
93         }, 0x01                             \
94 }
95
96 #define SYNT_NETLOGON_V1                    \
97 {                                           \
98         {                                   \
99                 0x12345678, 0x1234, 0xabcd, \
100                 { 0xef, 0x00, 0x01, 0x23,   \
101                 0x45, 0x67, 0xcf, 0xfb }    \
102         }, 0x01                             \
103 }
104
105 #define SYNT_WINREG_V1                      \
106 {                                           \
107         {                                   \
108                 0x338cd001, 0x2244, 0x31f1, \
109                 { 0xaa, 0xaa, 0x90, 0x00,   \
110                 0x38, 0x00, 0x10, 0x03 }    \
111         }, 0x01                             \
112 }
113
114 #define SYNT_SPOOLSS_V1                     \
115 {                                           \
116         {                                   \
117                 0x12345678, 0x1234, 0xabcd, \
118                 { 0xef, 0x00, 0x01, 0x23,   \
119                 0x45, 0x67, 0x89, 0xab }    \
120         }, 0x01                             \
121 }
122
123 #define SYNT_NONE_V0                        \
124 {                                           \
125         {                                   \
126                 0x0, 0x0, 0x0,              \
127                 { 0x00, 0x00, 0x00, 0x00,   \
128                 0x00, 0x00, 0x00, 0x00 }    \
129         }, 0x00                             \
130 }
131
132 #define SYNT_NETDFS_V3                      \
133 {                                           \
134         {                                   \
135                 0x4fc742e0, 0x4a10, 0x11cf, \
136                 { 0x82, 0x73, 0x00, 0xaa,   \
137                   0x00, 0x4a, 0xe6, 0x73 }  \
138         }, 0x03                             \
139 }
140
141 #define SYNT_ECHO_V1                        \
142 {                                           \
143         {                                   \
144                 0x60a15ec5, 0x4de8, 0x11d7, \
145                 { 0xa6, 0x37, 0x00, 0x50,   \
146                   0x56, 0xa2, 0x01, 0x82 }  \
147         }, 0x01                             \
148 }
149
150 #define SYNT_SHUTDOWN_V1                    \
151 {                                           \
152         {                                   \
153                 0x894de0c0, 0x0d55, 0x11d3, \
154                 { 0xa3, 0x22, 0x00, 0xc0,   \
155                   0x4f, 0xa3, 0x21, 0xa1 }  \
156         }, 0x01                             \
157 }
158
159 #define SYNT_EPM_V3                         \
160 {                                           \
161         {                                   \
162                 0xe1af8308, 0x5d1f, 0x11c9, \
163                 {  0x91, 0xa4, 0x08, 0x00,  \
164                    0x2b, 0x14, 0xa0, 0xfa } \
165         }, 0x03                             \
166 }
167
168 /*
169  * IMPORTANT!!  If you update this structure, make sure to
170  * update the index #defines in smb.h.
171  */
172
173 const struct pipe_id_info pipe_names [] =
174 {
175         /* client pipe , abstract syntax       , server pipe   , transfer syntax */
176         { PIPE_LSARPC  , SYNT_LSARPC_V0        , PIPE_LSASS    , TRANS_SYNT_V2 },
177         { PIPE_LSARPC  , SYNT_LSARPC_V0_DS     , PIPE_LSASS    , TRANS_SYNT_V2 },
178         { PIPE_SAMR    , SYNT_SAMR_V1          , PIPE_LSASS    , TRANS_SYNT_V2 },
179         { PIPE_NETLOGON, SYNT_NETLOGON_V1      , PIPE_LSASS    , TRANS_SYNT_V2 },
180         { PIPE_SRVSVC  , SYNT_SRVSVC_V3        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
181         { PIPE_WKSSVC  , SYNT_WKSSVC_V1        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
182         { PIPE_WINREG  , SYNT_WINREG_V1        , PIPE_WINREG   , TRANS_SYNT_V2 },
183         { PIPE_SPOOLSS , SYNT_SPOOLSS_V1       , PIPE_SPOOLSS  , TRANS_SYNT_V2 },
184         { PIPE_NETDFS  , SYNT_NETDFS_V3        , PIPE_NETDFS   , TRANS_SYNT_V2 },
185         { PIPE_ECHO    , SYNT_ECHO_V1          , PIPE_ECHO     , TRANS_SYNT_V2 },
186         { PIPE_SHUTDOWN, SYNT_SHUTDOWN_V1      , PIPE_SHUTDOWN , TRANS_SYNT_V2 },
187         { PIPE_EPM     , SYNT_EPM_V3           , PIPE_EPM      , TRANS_SYNT_V2 },
188         { NULL         , SYNT_NONE_V0          , NULL          , SYNT_NONE_V0  }
189 };
190
191 /*******************************************************************
192  Inits an RPC_HDR structure.
193 ********************************************************************/
194
195 void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
196                                 uint32 call_id, int data_len, int auth_len)
197 {
198         hdr->major        = 5;               /* RPC version 5 */
199         hdr->minor        = 0;               /* minor version 0 */
200         hdr->pkt_type     = pkt_type;        /* RPC packet type */
201         hdr->flags        = flags;           /* dce/rpc flags */
202         hdr->pack_type[0] = 0x10;            /* little-endian data representation */
203         hdr->pack_type[1] = 0;               /* packed data representation */
204         hdr->pack_type[2] = 0;               /* packed data representation */
205         hdr->pack_type[3] = 0;               /* packed data representation */
206         hdr->frag_len     = data_len;        /* fragment length, fill in later */
207         hdr->auth_len     = auth_len;        /* authentication length */
208         hdr->call_id      = call_id;         /* call identifier - match incoming RPC */
209 }
210
211 /*******************************************************************
212  Reads or writes an RPC_HDR structure.
213 ********************************************************************/
214
215 BOOL smb_io_rpc_hdr(const char *desc,  RPC_HDR *rpc, prs_struct *ps, int depth)
216 {
217         if (rpc == NULL)
218                 return False;
219
220         prs_debug(ps, depth, desc, "smb_io_rpc_hdr");
221         depth++;
222
223         if(!prs_uint8 ("major     ", ps, depth, &rpc->major))
224                 return False;
225
226         if(!prs_uint8 ("minor     ", ps, depth, &rpc->minor))
227                 return False;
228         if(!prs_uint8 ("pkt_type  ", ps, depth, &rpc->pkt_type))
229                 return False;
230         if(!prs_uint8 ("flags     ", ps, depth, &rpc->flags))
231                 return False;
232
233         /* We always marshall in little endian format. */
234         if (MARSHALLING(ps))
235                 rpc->pack_type[0] = 0x10;
236
237         if(!prs_uint8("pack_type0", ps, depth, &rpc->pack_type[0]))
238                 return False;
239         if(!prs_uint8("pack_type1", ps, depth, &rpc->pack_type[1]))
240                 return False;
241         if(!prs_uint8("pack_type2", ps, depth, &rpc->pack_type[2]))
242                 return False;
243         if(!prs_uint8("pack_type3", ps, depth, &rpc->pack_type[3]))
244                 return False;
245
246         /*
247          * If reading and pack_type[0] == 0 then the data is in big-endian
248          * format. Set the flag in the prs_struct to specify reverse-endainness.
249          */
250
251         if (UNMARSHALLING(ps) && rpc->pack_type[0] == 0) {
252                 DEBUG(10,("smb_io_rpc_hdr: PDU data format is big-endian. Setting flag.\n"));
253                 prs_set_endian_data(ps, RPC_BIG_ENDIAN);
254         }
255
256         if(!prs_uint16("frag_len  ", ps, depth, &rpc->frag_len))
257                 return False;
258         if(!prs_uint16("auth_len  ", ps, depth, &rpc->auth_len))
259                 return False;
260         if(!prs_uint32("call_id   ", ps, depth, &rpc->call_id))
261                 return False;
262         return True;
263 }
264
265 /*******************************************************************
266  Reads or writes an RPC_UUID structure.
267 ********************************************************************/
268
269 BOOL smb_io_rpc_uuid(const char *desc, RPC_UUID *uuid, prs_struct *ps, int depth)
270 {
271         if (uuid == NULL)
272                 return False;
273
274         prs_debug(ps, depth, desc, "smb_io_rpc_uuid");
275         depth++;
276
277         if(!prs_uint32 ("data   ", ps, depth, &uuid->time_low))
278                 return False;
279         if(!prs_uint16 ("data   ", ps, depth, &uuid->time_mid))
280                 return False;
281         if(!prs_uint16 ("data   ", ps, depth, &uuid->time_hi_and_version))
282                 return False;
283
284         if(!prs_uint8s (False, "data   ", ps, depth, uuid->remaining, sizeof(uuid->remaining)))
285                 return False;
286
287         return True;
288 }
289
290 /*******************************************************************
291  Reads or writes an RPC_IFACE structure.
292 ********************************************************************/
293
294 static BOOL smb_io_rpc_iface(const char *desc, RPC_IFACE *ifc, prs_struct *ps, int depth)
295 {
296         if (ifc == NULL)
297                 return False;
298
299         prs_debug(ps, depth, desc, "smb_io_rpc_iface");
300         depth++;
301
302         if (!prs_align(ps))
303                 return False;
304
305         if (!smb_io_rpc_uuid(  "uuid", &ifc->uuid, ps, depth))
306                 return False;
307
308         if(!prs_uint32 ("version", ps, depth, &ifc->version))
309                 return False;
310
311         return True;
312 }
313
314 /*******************************************************************
315  Inits an RPC_ADDR_STR structure.
316 ********************************************************************/
317
318 static void init_rpc_addr_str(RPC_ADDR_STR *str, const char *name)
319 {
320         str->len = strlen(name) + 1;
321         fstrcpy(str->str, name);
322 }
323
324 /*******************************************************************
325  Reads or writes an RPC_ADDR_STR structure.
326 ********************************************************************/
327
328 static BOOL smb_io_rpc_addr_str(const char *desc,  RPC_ADDR_STR *str, prs_struct *ps, int depth)
329 {
330         if (str == NULL)
331                 return False;
332
333         prs_debug(ps, depth, desc, "smb_io_rpc_addr_str");
334         depth++;
335         if(!prs_align(ps))
336                 return False;
337
338         if(!prs_uint16 (      "len", ps, depth, &str->len))
339                 return False;
340         if(!prs_uint8s (True, "str", ps, depth, (uchar*)str->str, MIN(str->len, sizeof(str->str)) ))
341                 return False;
342         return True;
343 }
344
345 /*******************************************************************
346  Inits an RPC_HDR_BBA structure.
347 ********************************************************************/
348
349 static void init_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid)
350 {
351         bba->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */
352         bba->max_rsize = max_rsize; /* max receive fragment size (0x1630) */   
353         bba->assoc_gid = assoc_gid; /* associated group id (0x0) */ 
354 }
355
356 /*******************************************************************
357  Reads or writes an RPC_HDR_BBA structure.
358 ********************************************************************/
359
360 static BOOL smb_io_rpc_hdr_bba(const char *desc,  RPC_HDR_BBA *rpc, prs_struct *ps, int depth)
361 {
362         if (rpc == NULL)
363                 return False;
364
365         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_bba");
366         depth++;
367
368         if(!prs_uint16("max_tsize", ps, depth, &rpc->max_tsize))
369                 return False;
370         if(!prs_uint16("max_rsize", ps, depth, &rpc->max_rsize))
371                 return False;
372         if(!prs_uint32("assoc_gid", ps, depth, &rpc->assoc_gid))
373                 return False;
374         return True;
375 }
376
377 /*******************************************************************
378  Inits an RPC_HDR_RB structure.
379 ********************************************************************/
380
381 void init_rpc_hdr_rb(RPC_HDR_RB *rpc, 
382                                 uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
383                                 uint32 num_elements, uint16 context_id, uint8 num_syntaxes,
384                                 RPC_IFACE *abstract, RPC_IFACE *transfer)
385 {
386         init_rpc_hdr_bba(&rpc->bba, max_tsize, max_rsize, assoc_gid);
387
388         rpc->num_elements = num_elements ; /* the number of elements (0x1) */
389         rpc->context_id   = context_id   ; /* presentation context identifier (0x0) */
390         rpc->num_syntaxes = num_syntaxes ; /* the number of syntaxes (has always been 1?)(0x1) */
391
392         /* num and vers. of interface client is using */
393         rpc->abstract = *abstract;
394
395         /* num and vers. of interface to use for replies */
396         rpc->transfer = *transfer;
397 }
398
399 /*******************************************************************
400  Reads or writes an RPC_HDR_RB structure.
401 ********************************************************************/
402
403 BOOL smb_io_rpc_hdr_rb(const char *desc, RPC_HDR_RB *rpc, prs_struct *ps, int depth)
404 {
405         if (rpc == NULL)
406                 return False;
407
408         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_rb");
409         depth++;
410
411         if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth))
412                 return False;
413
414         if(!prs_uint32("num_elements", ps, depth, &rpc->num_elements))
415                 return False;
416         if(!prs_uint16("context_id  ", ps, depth, &rpc->context_id ))
417                 return False;
418         if(!prs_uint8 ("num_syntaxes", ps, depth, &rpc->num_syntaxes))
419                 return False;
420
421         if(!smb_io_rpc_iface("", &rpc->abstract, ps, depth))
422                 return False;
423         if(!smb_io_rpc_iface("", &rpc->transfer, ps, depth))
424                 return False;
425
426         return True;
427 }
428
429 /*******************************************************************
430  Inits an RPC_RESULTS structure.
431
432  lkclXXXX only one reason at the moment!
433 ********************************************************************/
434
435 static void init_rpc_results(RPC_RESULTS *res, 
436                                 uint8 num_results, uint16 result, uint16 reason)
437 {
438         res->num_results = num_results; /* the number of results (0x01) */
439         res->result      = result     ;  /* result (0x00 = accept) */
440         res->reason      = reason     ;  /* reason (0x00 = no reason specified) */
441 }
442
443 /*******************************************************************
444  Reads or writes an RPC_RESULTS structure.
445
446  lkclXXXX only one reason at the moment!
447 ********************************************************************/
448
449 static BOOL smb_io_rpc_results(const char *desc, RPC_RESULTS *res, prs_struct *ps, int depth)
450 {
451         if (res == NULL)
452                 return False;
453
454         prs_debug(ps, depth, desc, "smb_io_rpc_results");
455         depth++;
456
457         if(!prs_align(ps))
458                 return False;
459         
460         if(!prs_uint8 ("num_results", ps, depth, &res->num_results))    
461                 return False;
462
463         if(!prs_align(ps))
464                 return False;
465         
466         if(!prs_uint16("result     ", ps, depth, &res->result))
467                 return False;
468         if(!prs_uint16("reason     ", ps, depth, &res->reason))
469                 return False;
470         return True;
471 }
472
473 /*******************************************************************
474  Init an RPC_HDR_BA structure.
475
476  lkclXXXX only one reason at the moment!
477
478 ********************************************************************/
479
480 void init_rpc_hdr_ba(RPC_HDR_BA *rpc, 
481                                 uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
482                                 const char *pipe_addr,
483                                 uint8 num_results, uint16 result, uint16 reason,
484                                 RPC_IFACE *transfer)
485 {
486         init_rpc_hdr_bba (&rpc->bba, max_tsize, max_rsize, assoc_gid);
487         init_rpc_addr_str(&rpc->addr, pipe_addr);
488         init_rpc_results (&rpc->res, num_results, result, reason);
489
490         /* the transfer syntax from the request */
491         memcpy(&rpc->transfer, transfer, sizeof(rpc->transfer));
492 }
493
494 /*******************************************************************
495  Reads or writes an RPC_HDR_BA structure.
496 ********************************************************************/
497
498 BOOL smb_io_rpc_hdr_ba(const char *desc, RPC_HDR_BA *rpc, prs_struct *ps, int depth)
499 {
500         if (rpc == NULL)
501                 return False;
502
503         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_ba");
504         depth++;
505
506         if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth))
507                 return False;
508         if(!smb_io_rpc_addr_str("", &rpc->addr, ps, depth))
509                 return False;
510         if(!smb_io_rpc_results("", &rpc->res, ps, depth))
511                 return False;
512         if(!smb_io_rpc_iface("", &rpc->transfer, ps, depth))
513                 return False;
514         return True;
515 }
516
517 /*******************************************************************
518  Init an RPC_HDR_REQ structure.
519 ********************************************************************/
520
521 void init_rpc_hdr_req(RPC_HDR_REQ *hdr, uint32 alloc_hint, uint16 opnum)
522 {
523         hdr->alloc_hint   = alloc_hint; /* allocation hint */
524         hdr->context_id   = 0;         /* presentation context identifier */
525         hdr->opnum        = opnum;     /* opnum */
526 }
527
528 /*******************************************************************
529  Reads or writes an RPC_HDR_REQ structure.
530 ********************************************************************/
531
532 BOOL smb_io_rpc_hdr_req(const char *desc, RPC_HDR_REQ *rpc, prs_struct *ps, int depth)
533 {
534         if (rpc == NULL)
535                 return False;
536
537         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_req");
538         depth++;
539
540         if(!prs_uint32("alloc_hint", ps, depth, &rpc->alloc_hint))
541                 return False;
542         if(!prs_uint16("context_id", ps, depth, &rpc->context_id))
543                 return False;
544         if(!prs_uint16("opnum     ", ps, depth, &rpc->opnum))
545                 return False;
546         return True;
547 }
548
549 /*******************************************************************
550  Reads or writes an RPC_HDR_RESP structure.
551 ********************************************************************/
552
553 BOOL smb_io_rpc_hdr_resp(const char *desc, RPC_HDR_RESP *rpc, prs_struct *ps, int depth)
554 {
555         if (rpc == NULL)
556                 return False;
557
558         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_resp");
559         depth++;
560
561         if(!prs_uint32("alloc_hint", ps, depth, &rpc->alloc_hint))
562                 return False;
563         if(!prs_uint16("context_id", ps, depth, &rpc->context_id))
564                 return False;
565         if(!prs_uint8 ("cancel_ct ", ps, depth, &rpc->cancel_count))
566                 return False;
567         if(!prs_uint8 ("reserved  ", ps, depth, &rpc->reserved))
568                 return False;
569         return True;
570 }
571
572 /*******************************************************************
573  Reads or writes an RPC_HDR_FAULT structure.
574 ********************************************************************/
575
576 BOOL smb_io_rpc_hdr_fault(const char *desc, RPC_HDR_FAULT *rpc, prs_struct *ps, int depth)
577 {
578         if (rpc == NULL)
579                 return False;
580
581         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_fault");
582         depth++;
583
584         if(!prs_ntstatus("status  ", ps, depth, &rpc->status))
585                 return False;
586         if(!prs_uint32("reserved", ps, depth, &rpc->reserved))
587                 return False;
588
589     return True;
590 }
591
592 /*******************************************************************
593  Init an RPC_HDR_AUTHA structure.
594 ********************************************************************/
595
596 void init_rpc_hdr_autha(RPC_HDR_AUTHA *rai,
597                                 uint16 max_tsize, uint16 max_rsize,
598                                 uint8 auth_type, uint8 auth_level,
599                                 uint8 stub_type_len)
600 {
601         rai->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */
602         rai->max_rsize = max_rsize; /* max receive fragment size (0x1630) */   
603
604         rai->auth_type     = auth_type; /* nt lm ssp 0x0a */
605         rai->auth_level    = auth_level; /* 0x06 */
606         rai->stub_type_len = stub_type_len; /* 0x00 */
607         rai->padding       = 0; /* padding 0x00 */
608
609         rai->unknown       = 0x0014a0c0; /* non-zero pointer to something */
610 }
611
612 /*******************************************************************
613  Reads or writes an RPC_HDR_AUTHA structure.
614 ********************************************************************/
615
616 BOOL smb_io_rpc_hdr_autha(const char *desc, RPC_HDR_AUTHA *rai, prs_struct *ps, int depth)
617 {
618         if (rai == NULL)
619                 return False;
620
621         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_autha");
622         depth++;
623
624         if(!prs_uint16("max_tsize    ", ps, depth, &rai->max_tsize))
625                 return False;
626         if(!prs_uint16("max_rsize    ", ps, depth, &rai->max_rsize))
627                 return False;
628
629         if(!prs_uint8 ("auth_type    ", ps, depth, &rai->auth_type)) /* 0x0a nt lm ssp */
630                 return False;
631         if(!prs_uint8 ("auth_level   ", ps, depth, &rai->auth_level)) /* 0x06 */
632                 return False;
633         if(!prs_uint8 ("stub_type_len", ps, depth, &rai->stub_type_len))
634                 return False;
635         if(!prs_uint8 ("padding      ", ps, depth, &rai->padding))
636                 return False;
637
638         if(!prs_uint32("unknown      ", ps, depth, &rai->unknown)) /* 0x0014a0c0 */
639                 return False;
640
641         return True;
642 }
643
644 /*******************************************************************
645  Inits an RPC_HDR_AUTH structure.
646 ********************************************************************/
647
648 void init_rpc_hdr_auth(RPC_HDR_AUTH *rai,
649                                 uint8 auth_type, uint8 auth_level,
650                                 uint8 padding,
651                                 uint32 ptr)
652 {
653         rai->auth_type     = auth_type; /* nt lm ssp 0x0a */
654         rai->auth_level    = auth_level; /* 0x06 */
655         rai->padding       = padding;
656         rai->reserved      = 0;
657
658         rai->auth_context  = ptr; /* non-zero pointer to something */
659 }
660
661 /*******************************************************************
662  Reads or writes an RPC_HDR_AUTH structure.
663 ********************************************************************/
664
665 BOOL smb_io_rpc_hdr_auth(const char *desc, RPC_HDR_AUTH *rai, prs_struct *ps, int depth)
666 {
667         if (rai == NULL)
668                 return False;
669
670         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_auth");
671         depth++;
672
673         if(!prs_align(ps))
674                 return False;
675
676         if(!prs_uint8 ("auth_type    ", ps, depth, &rai->auth_type)) /* 0x0a nt lm ssp */
677                 return False;
678         if(!prs_uint8 ("auth_level   ", ps, depth, &rai->auth_level)) /* 0x06 */
679                 return False;
680         if(!prs_uint8 ("padding      ", ps, depth, &rai->padding))
681                 return False;
682         if(!prs_uint8 ("reserved     ", ps, depth, &rai->reserved))
683                 return False;
684         if(!prs_uint32("auth_context ", ps, depth, &rai->auth_context))
685                 return False;
686
687         return True;
688 }
689
690 /*******************************************************************
691  Checks an RPC_AUTH_VERIFIER structure.
692 ********************************************************************/
693
694 BOOL rpc_auth_verifier_chk(RPC_AUTH_VERIFIER *rav,
695                                 const char *signature, uint32 msg_type)
696 {
697         return (strequal(rav->signature, signature) && rav->msg_type == msg_type);
698 }
699
700 /*******************************************************************
701  Inits an RPC_AUTH_VERIFIER structure.
702 ********************************************************************/
703
704 void init_rpc_auth_verifier(RPC_AUTH_VERIFIER *rav,
705                                 const char *signature, uint32 msg_type)
706 {
707         fstrcpy(rav->signature, signature); /* "NTLMSSP" */
708         rav->msg_type = msg_type; /* NTLMSSP_MESSAGE_TYPE */
709 }
710
711 /*******************************************************************
712  Reads or writes an RPC_AUTH_VERIFIER structure.
713 ********************************************************************/
714
715 BOOL smb_io_rpc_auth_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth)
716 {
717         if (rav == NULL)
718                 return False;
719
720         prs_debug(ps, depth, desc, "smb_io_rpc_auth_verifier");
721         depth++;
722
723         /* "NTLMSSP" */
724         if(!prs_string("signature", ps, depth, rav->signature,
725                         sizeof(rav->signature)))
726                 return False;
727         if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type)) /* NTLMSSP_MESSAGE_TYPE */
728                 return False;
729
730         return True;
731 }
732
733 /*******************************************************************
734  This parses an RPC_AUTH_VERIFIER for NETLOGON schannel. I think
735  assuming "NTLMSSP" in sm_io_rpc_auth_verifier is somewhat wrong.
736  I have to look at that later...
737 ********************************************************************/
738
739 BOOL smb_io_rpc_netsec_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth)
740 {
741         if (rav == NULL)
742                 return False;
743
744         prs_debug(ps, depth, desc, "smb_io_rpc_auth_verifier");
745         depth++;
746
747         if(!prs_string("signature", ps, depth, rav->signature, sizeof(rav->signature)))
748                 return False;
749         if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type))
750                 return False;
751
752         return True;
753 }
754
755 /*******************************************************************
756  Inits an RPC_AUTH_NTLMSSP_NEG structure.
757 ********************************************************************/
758
759 void init_rpc_auth_ntlmssp_neg(RPC_AUTH_NTLMSSP_NEG *neg,
760                                 uint32 neg_flgs,
761                                 const char *myname, const char *domain)
762 {
763         int len_myname = strlen(myname);
764         int len_domain = strlen(domain);
765
766         neg->neg_flgs = neg_flgs ; /* 0x00b2b3 */
767
768         init_str_hdr(&neg->hdr_domain, len_domain, len_domain, 0x20 + len_myname); 
769         init_str_hdr(&neg->hdr_myname, len_myname, len_myname, 0x20); 
770
771         fstrcpy(neg->myname, myname);
772         fstrcpy(neg->domain, domain);
773 }
774
775 /*******************************************************************
776  Reads or writes an RPC_AUTH_NTLMSSP_NEG structure.
777
778  *** lkclXXXX HACK ALERT! ***
779 ********************************************************************/
780
781 BOOL smb_io_rpc_auth_ntlmssp_neg(const char *desc, RPC_AUTH_NTLMSSP_NEG *neg, prs_struct *ps, int depth)
782 {
783         uint32 start_offset = prs_offset(ps);
784         if (neg == NULL)
785                 return False;
786
787         prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_neg");
788         depth++;
789
790         if(!prs_uint32("neg_flgs ", ps, depth, &neg->neg_flgs))
791                 return False;
792
793         if (ps->io) {
794                 uint32 old_offset;
795                 uint32 old_neg_flags = neg->neg_flgs;
796
797                 /* reading */
798
799                 ZERO_STRUCTP(neg);
800
801                 neg->neg_flgs = old_neg_flags;
802
803                 if(!smb_io_strhdr("hdr_domain", &neg->hdr_domain, ps, depth))
804                         return False;
805                 if(!smb_io_strhdr("hdr_myname", &neg->hdr_myname, ps, depth))
806                         return False;
807
808                 old_offset = prs_offset(ps);
809
810                 if(!prs_set_offset(ps, neg->hdr_myname.buffer + start_offset - 12))
811                         return False;
812
813                 if(!prs_uint8s(True, "myname", ps, depth, (uint8*)neg->myname, 
814                                 MIN(neg->hdr_myname.str_str_len, sizeof(neg->myname))))
815                         return False;
816
817                 old_offset += neg->hdr_myname.str_str_len;
818
819                 if(!prs_set_offset(ps, neg->hdr_domain.buffer + start_offset - 12))
820                         return False;
821
822                 if(!prs_uint8s(True, "domain", ps, depth, (uint8*)neg->domain, 
823                         MIN(neg->hdr_domain.str_str_len, sizeof(neg->domain  ))))
824                         return False;
825
826                 old_offset += neg->hdr_domain  .str_str_len;
827
828                 if(!prs_set_offset(ps, old_offset))
829                         return False;
830         } else {
831                 /* writing */
832                 if(!smb_io_strhdr("hdr_domain", &neg->hdr_domain, ps, depth))
833                         return False;
834                 if(!smb_io_strhdr("hdr_myname", &neg->hdr_myname, ps, depth))
835                         return False;
836
837                 if(!prs_uint8s(True, "myname", ps, depth, (uint8*)neg->myname, 
838                                         MIN(neg->hdr_myname.str_str_len, sizeof(neg->myname))))
839                         return False;
840                 if(!prs_uint8s(True, "domain", ps, depth, (uint8*)neg->domain, 
841                                         MIN(neg->hdr_domain.str_str_len, sizeof(neg->domain  ))))
842                         return False;
843         }
844
845         return True;
846 }
847
848 /*******************************************************************
849 creates an RPC_AUTH_NTLMSSP_CHAL structure.
850 ********************************************************************/
851
852 void init_rpc_auth_ntlmssp_chal(RPC_AUTH_NTLMSSP_CHAL *chl,
853                                 uint32 neg_flags,
854                                 uint8 challenge[8])
855 {
856         chl->unknown_1 = 0x0; 
857         chl->unknown_2 = 0x00000028;
858         chl->neg_flags = neg_flags; /* 0x0082b1 */
859
860         memcpy(chl->challenge, challenge, sizeof(chl->challenge)); 
861         memset((char *)chl->reserved , '\0', sizeof(chl->reserved)); 
862 }
863
864 /*******************************************************************
865  Reads or writes an RPC_AUTH_NTLMSSP_CHAL structure.
866 ********************************************************************/
867
868 BOOL smb_io_rpc_auth_ntlmssp_chal(const char *desc, RPC_AUTH_NTLMSSP_CHAL *chl, prs_struct *ps, int depth)
869 {
870         if (chl == NULL)
871                 return False;
872
873         prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_chal");
874         depth++;
875
876         if(!prs_uint32("unknown_1", ps, depth, &chl->unknown_1)) /* 0x0000 0000 */
877                 return False;
878         if(!prs_uint32("unknown_2", ps, depth, &chl->unknown_2)) /* 0x0000 b2b3 */
879                 return False;
880         if(!prs_uint32("neg_flags", ps, depth, &chl->neg_flags)) /* 0x0000 82b1 */
881                 return False;
882
883         if(!prs_uint8s (False, "challenge", ps, depth, chl->challenge, sizeof(chl->challenge)))
884                 return False;
885         if(!prs_uint8s (False, "reserved ", ps, depth, chl->reserved , sizeof(chl->reserved )))
886                 return False;
887
888         return True;
889 }
890
891 /*******************************************************************
892  Inits an RPC_AUTH_NTLMSSP_RESP structure.
893
894  *** lkclXXXX FUDGE!  HAVE TO MANUALLY SPECIFY OFFSET HERE (0x1c bytes) ***
895  *** lkclXXXX the actual offset is at the start of the auth verifier    ***
896 ********************************************************************/
897
898 void init_rpc_auth_ntlmssp_resp(RPC_AUTH_NTLMSSP_RESP *rsp,
899                                 uchar lm_resp[24], uchar nt_resp[24],
900                                 const char *domain, const char *user, const char *wks,
901                                 uint32 neg_flags)
902 {
903         uint32 offset;
904         int dom_len = strlen(domain);
905         int wks_len = strlen(wks);
906         int usr_len = strlen(user);
907         int lm_len  = (lm_resp != NULL) ? 24 : 0;
908         int nt_len  = (nt_resp != NULL) ? 24 : 0;
909
910         DEBUG(5,("make_rpc_auth_ntlmssp_resp\n"));
911
912 #ifdef DEBUG_PASSWORD
913         DEBUG(100,("lm_resp\n"));
914         dump_data(100, (char *)lm_resp, 24);
915         DEBUG(100,("nt_resp\n"));
916         dump_data(100, (char *)nt_resp, 24);
917 #endif
918
919         DEBUG(6,("dom: %s user: %s wks: %s neg_flgs: 0x%x\n",
920                   domain, user, wks, neg_flags));
921
922         offset = 0x40;
923
924         if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) {
925                 dom_len *= 2;
926                 wks_len *= 2;
927                 usr_len *= 2;
928         }
929
930         init_str_hdr(&rsp->hdr_domain, dom_len, dom_len, offset);
931         offset += dom_len;
932
933         init_str_hdr(&rsp->hdr_usr, usr_len, usr_len, offset);
934         offset += usr_len;
935
936         init_str_hdr(&rsp->hdr_wks, wks_len, wks_len, offset);
937         offset += wks_len;
938
939         init_str_hdr(&rsp->hdr_lm_resp, lm_len, lm_len, offset);
940         offset += lm_len;
941
942         init_str_hdr(&rsp->hdr_nt_resp, nt_len, nt_len, offset);
943         offset += nt_len;
944
945         init_str_hdr(&rsp->hdr_sess_key, 0, 0, offset);
946
947         rsp->neg_flags = neg_flags;
948
949         memcpy(rsp->lm_resp, lm_resp, 24);
950         memcpy(rsp->nt_resp, nt_resp, 24);
951
952         if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) {
953                 rpcstr_push(rsp->domain, domain, sizeof(rsp->domain), 0);
954                 rpcstr_push(rsp->user, user, sizeof(rsp->user), 0);
955                 rpcstr_push(rsp->wks, wks, sizeof(rsp->wks), 0);
956         } else {
957                 fstrcpy(rsp->domain, domain);
958                 fstrcpy(rsp->user, user);
959                 fstrcpy(rsp->wks, wks);
960         }
961         
962         rsp->sess_key[0] = 0;
963 }
964
965 /*******************************************************************
966  Reads or writes an RPC_AUTH_NTLMSSP_RESP structure.
967
968  *** lkclXXXX FUDGE!  HAVE TO MANUALLY SPECIFY OFFSET HERE (0x1c bytes) ***
969  *** lkclXXXX the actual offset is at the start of the auth verifier    ***
970 ********************************************************************/
971
972 BOOL smb_io_rpc_auth_ntlmssp_resp(const char *desc, RPC_AUTH_NTLMSSP_RESP *rsp, prs_struct *ps, int depth)
973 {
974         if (rsp == NULL)
975                 return False;
976
977         prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_resp");
978         depth++;
979
980         if (ps->io) {
981                 uint32 old_offset;
982
983                 /* reading */
984
985                 ZERO_STRUCTP(rsp);
986
987                 if(!smb_io_strhdr("hdr_lm_resp ", &rsp->hdr_lm_resp, ps, depth))
988                         return False;
989                 if(!smb_io_strhdr("hdr_nt_resp ", &rsp->hdr_nt_resp, ps, depth))
990                         return False;
991                 if(!smb_io_strhdr("hdr_domain  ", &rsp->hdr_domain, ps, depth))
992                         return False;
993                 if(!smb_io_strhdr("hdr_user    ", &rsp->hdr_usr, ps, depth))
994                         return False;
995                 if(!smb_io_strhdr("hdr_wks     ", &rsp->hdr_wks, ps, depth)) 
996                         return False;
997                 if(!smb_io_strhdr("hdr_sess_key", &rsp->hdr_sess_key, ps, depth))
998                         return False;
999
1000                 if(!prs_uint32("neg_flags", ps, depth, &rsp->neg_flags)) /* 0x0000 82b1 */
1001                         return False;
1002
1003                 old_offset = prs_offset(ps);
1004
1005                 if(!prs_set_offset(ps, rsp->hdr_domain.buffer + 0xc))
1006                         return False;
1007
1008                 if(!prs_uint8s(True , "domain  ", ps, depth, (uint8*)rsp->domain,
1009                                 MIN(rsp->hdr_domain.str_str_len, sizeof(rsp->domain))))
1010                         return False;
1011
1012                 old_offset += rsp->hdr_domain.str_str_len;
1013
1014                 if(!prs_set_offset(ps, rsp->hdr_usr.buffer + 0xc))
1015                         return False;
1016
1017                 if(!prs_uint8s(True , "user    ", ps, depth, (uint8*)rsp->user,
1018                                 MIN(rsp->hdr_usr.str_str_len, sizeof(rsp->user))))
1019                         return False;
1020
1021                 old_offset += rsp->hdr_usr.str_str_len;
1022
1023                 if(!prs_set_offset(ps, rsp->hdr_wks.buffer + 0xc))
1024                         return False;
1025
1026                 if(!prs_uint8s(True, "wks     ", ps, depth, (uint8*)rsp->wks,
1027                                 MIN(rsp->hdr_wks.str_str_len, sizeof(rsp->wks))))
1028                         return False;
1029
1030                 old_offset += rsp->hdr_wks.str_str_len;
1031
1032                 if(!prs_set_offset(ps, rsp->hdr_lm_resp.buffer + 0xc))
1033                         return False;
1034
1035                 if(!prs_uint8s(False, "lm_resp ", ps, depth, (uint8*)rsp->lm_resp,
1036                                 MIN(rsp->hdr_lm_resp.str_str_len, sizeof(rsp->lm_resp ))))
1037                         return False;
1038
1039                 old_offset += rsp->hdr_lm_resp.str_str_len;
1040
1041                 if(!prs_set_offset(ps, rsp->hdr_nt_resp.buffer + 0xc))
1042                         return False;
1043
1044                 if(!prs_uint8s(False, "nt_resp ", ps, depth, (uint8*)rsp->nt_resp,
1045                                 MIN(rsp->hdr_nt_resp.str_str_len, sizeof(rsp->nt_resp ))))
1046                         return False;
1047
1048                 old_offset += rsp->hdr_nt_resp.str_str_len;
1049
1050                 if (rsp->hdr_sess_key.str_str_len != 0) {
1051
1052                         if(!prs_set_offset(ps, rsp->hdr_sess_key.buffer + 0x10))
1053                                 return False;
1054
1055                         old_offset += rsp->hdr_sess_key.str_str_len;
1056
1057                         if(!prs_uint8s(False, "sess_key", ps, depth, (uint8*)rsp->sess_key,
1058                                         MIN(rsp->hdr_sess_key.str_str_len, sizeof(rsp->sess_key))))
1059                                 return False;
1060                 }
1061
1062                 if(!prs_set_offset(ps, old_offset))
1063                         return False;
1064         } else {
1065                 /* writing */
1066                 if(!smb_io_strhdr("hdr_lm_resp ", &rsp->hdr_lm_resp, ps, depth))
1067                         return False;
1068                 if(!smb_io_strhdr("hdr_nt_resp ", &rsp->hdr_nt_resp, ps, depth))
1069                         return False;
1070                 if(!smb_io_strhdr("hdr_domain  ", &rsp->hdr_domain, ps, depth))
1071                         return False;
1072                 if(!smb_io_strhdr("hdr_user    ", &rsp->hdr_usr, ps, depth))
1073                         return False;
1074                 if(!smb_io_strhdr("hdr_wks     ", &rsp->hdr_wks, ps, depth))
1075                         return False;
1076                 if(!smb_io_strhdr("hdr_sess_key", &rsp->hdr_sess_key, ps, depth))
1077                         return False;
1078
1079                 if(!prs_uint32("neg_flags", ps, depth, &rsp->neg_flags)) /* 0x0000 82b1 */
1080                         return False;
1081
1082                 if(!prs_uint8s(True , "domain  ", ps, depth, (uint8*)rsp->domain,
1083                                 MIN(rsp->hdr_domain.str_str_len, sizeof(rsp->domain))))
1084                         return False;
1085
1086                 if(!prs_uint8s(True , "user    ", ps, depth, (uint8*)rsp->user,
1087                                 MIN(rsp->hdr_usr.str_str_len, sizeof(rsp->user))))
1088                         return False;
1089
1090                 if(!prs_uint8s(True , "wks     ", ps, depth, (uint8*)rsp->wks,
1091                                 MIN(rsp->hdr_wks.str_str_len, sizeof(rsp->wks))))
1092                         return False;
1093                 if(!prs_uint8s(False, "lm_resp ", ps, depth, (uint8*)rsp->lm_resp,
1094                                 MIN(rsp->hdr_lm_resp .str_str_len, sizeof(rsp->lm_resp))))
1095                         return False;
1096                 if(!prs_uint8s(False, "nt_resp ", ps, depth, (uint8*)rsp->nt_resp,
1097                                 MIN(rsp->hdr_nt_resp .str_str_len, sizeof(rsp->nt_resp ))))
1098                         return False;
1099                 if(!prs_uint8s(False, "sess_key", ps, depth, (uint8*)rsp->sess_key,
1100                                 MIN(rsp->hdr_sess_key.str_str_len, sizeof(rsp->sess_key))))
1101                         return False;
1102         }
1103
1104         return True;
1105 }
1106
1107 /*******************************************************************
1108  Checks an RPC_AUTH_NTLMSSP_CHK structure.
1109 ********************************************************************/
1110
1111 BOOL rpc_auth_ntlmssp_chk(RPC_AUTH_NTLMSSP_CHK *chk, uint32 crc32, uint32 seq_num)
1112 {
1113         if (chk == NULL)
1114                 return False;
1115
1116         if (chk->crc32 != crc32 ||
1117             chk->ver   != NTLMSSP_SIGN_VERSION ||
1118             chk->seq_num != seq_num)
1119         {
1120                 DEBUG(5,("verify failed - crc %x ver %x seq %d\n",
1121                          chk->crc32, chk->ver, chk->seq_num));
1122                         
1123                 DEBUG(5,("verify expect - crc %x ver %x seq %d\n",
1124                         crc32, NTLMSSP_SIGN_VERSION, seq_num));
1125                 return False;
1126         }
1127         return True;
1128 }
1129
1130 /*******************************************************************
1131  Inits an RPC_AUTH_NTLMSSP_CHK structure.
1132 ********************************************************************/
1133
1134 void init_rpc_auth_ntlmssp_chk(RPC_AUTH_NTLMSSP_CHK *chk,
1135                                 uint32 ver, uint32 crc32, uint32 seq_num)
1136 {
1137         chk->ver      = ver;
1138         chk->reserved = 0x0;
1139         chk->crc32    = crc32;
1140         chk->seq_num  = seq_num;
1141 }
1142
1143 /*******************************************************************
1144  Reads or writes an RPC_AUTH_NTLMSSP_CHK structure.
1145 ********************************************************************/
1146
1147 BOOL smb_io_rpc_auth_ntlmssp_chk(const char *desc, RPC_AUTH_NTLMSSP_CHK *chk, prs_struct *ps, int depth)
1148 {
1149         if (chk == NULL)
1150                 return False;
1151
1152         prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_chk");
1153         depth++;
1154
1155         if(!prs_align(ps))
1156                 return False;
1157
1158         if(!prs_uint32("ver     ", ps, depth, &chk->ver))
1159                 return False;
1160         if(!prs_uint32("reserved", ps, depth, &chk->reserved))
1161                 return False;
1162         if(!prs_uint32("crc32   ", ps, depth, &chk->crc32))
1163                 return False;
1164         if(!prs_uint32("seq_num ", ps, depth, &chk->seq_num))
1165                 return False;
1166
1167         return True;
1168 }
1169
1170 /*******************************************************************
1171 creates an RPC_AUTH_NETSEC_NEG structure.
1172 ********************************************************************/
1173 void init_rpc_auth_netsec_neg(RPC_AUTH_NETSEC_NEG *neg,
1174                               const char *domain, const char *myname)
1175 {
1176         neg->type1 = 0;
1177         neg->type2 = 0x3;
1178         fstrcpy(neg->domain, domain);
1179         fstrcpy(neg->myname, myname);
1180 }
1181
1182 /*******************************************************************
1183  Reads or writes an RPC_AUTH_NETSEC_NEG structure.
1184 ********************************************************************/
1185
1186 BOOL smb_io_rpc_auth_netsec_neg(const char *desc, RPC_AUTH_NETSEC_NEG *neg,
1187                                 prs_struct *ps, int depth)
1188 {
1189         if (neg == NULL)
1190                 return False;
1191
1192         prs_debug(ps, depth, desc, "smb_io_rpc_auth_netsec_neg");
1193         depth++;
1194
1195         if(!prs_align(ps))
1196                 return False;
1197
1198         if(!prs_uint32("type1", ps, depth, &neg->type1))
1199                 return False;
1200         if(!prs_uint32("type2", ps, depth, &neg->type2))
1201                 return False;
1202         if(!prs_string("domain  ", ps, depth, neg->domain, sizeof(neg->domain)))
1203                 return False;
1204         if(!prs_string("myname  ", ps, depth, neg->myname, sizeof(neg->myname)))
1205                 return False;
1206
1207         return True;
1208 }
1209
1210 /*******************************************************************
1211 reads or writes an RPC_AUTH_NETSEC_CHK structure.
1212 ********************************************************************/
1213 BOOL smb_io_rpc_auth_netsec_chk(const char *desc, RPC_AUTH_NETSEC_CHK * chk,
1214                                 prs_struct *ps, int depth)
1215 {
1216         if (chk == NULL)
1217                 return False;
1218
1219         prs_debug(ps, depth, desc, "smb_io_rpc_auth_netsec_chk");
1220         depth++;
1221
1222         prs_uint8s(False, "sig  ", ps, depth, chk->sig, sizeof(chk->sig));
1223         prs_uint8s(False, "seq_num", ps, depth, chk->seq_num, sizeof(chk->seq_num));
1224         prs_uint8s(False, "packet_digest", ps, depth, chk->packet_digest, sizeof(chk->packet_digest));
1225         prs_uint8s(False, "confounder", ps, depth, chk->confounder, sizeof(chk->confounder));
1226
1227         return True;
1228 }
1229