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