rpc_parse/parse_rpc.c

説明を見る。
00001 /* 
00002  *  Unix SMB/CIFS implementation.
00003  *  RPC Pipe client / server routines
00004  *  Copyright (C) Andrew Tridgell              1992-1997,
00005  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
00006  *  Copyright (C) Paul Ashton                       1997.
00007  *  Copyright (C) Jeremy Allison                    1999.
00008  *  
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *  
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *  
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022  */
00023 
00024 #include "includes.h"
00025 
00026 #undef DBGC_CLASS
00027 #define DBGC_CLASS DBGC_RPC_PARSE
00028 
00029 /*******************************************************************
00030 interface/version dce/rpc pipe identification
00031 ********************************************************************/
00032 
00033 #define TRANS_SYNT_V2                       \
00034 {                                           \
00035         {                                   \
00036                 0x8a885d04, 0x1ceb, 0x11c9, \
00037                 { 0x9f, 0xe8 },             \
00038                 { 0x08, 0x00,               \
00039                   0x2b, 0x10, 0x48, 0x60 }  \
00040         }, 0x02                             \
00041 }
00042 
00043 #define SYNT_NETLOGON_V2                    \
00044 {                                           \
00045         {                                   \
00046                 0x8a885d04, 0x1ceb, 0x11c9, \
00047                 { 0x9f, 0xe8 },             \
00048                 { 0x08, 0x00,               \
00049                   0x2b, 0x10, 0x48, 0x60 }  \
00050         }, 0x02                             \
00051 }
00052 
00053 #define SYNT_WKSSVC_V1                      \
00054 {                                           \
00055         {                                   \
00056                 0x6bffd098, 0xa112, 0x3610, \
00057                 { 0x98, 0x33 },             \
00058                 { 0x46, 0xc3,               \
00059                   0xf8, 0x7e, 0x34, 0x5a }  \
00060         }, 0x01                             \
00061 }
00062 
00063 #define SYNT_SRVSVC_V3                      \
00064 {                                           \
00065         {                                   \
00066                 0x4b324fc8, 0x1670, 0x01d3, \
00067                 { 0x12, 0x78 },             \
00068                 { 0x5a, 0x47,               \
00069                   0xbf, 0x6e, 0xe1, 0x88 }  \
00070         }, 0x03                             \
00071 }
00072 
00073 #define SYNT_LSARPC_V0                      \
00074 {                                           \
00075         {                                   \
00076                 0x12345778, 0x1234, 0xabcd, \
00077                 { 0xef, 0x00 },             \
00078                 { 0x01, 0x23,               \
00079                   0x45, 0x67, 0x89, 0xab }  \
00080         }, 0x00                             \
00081 }
00082 
00083 #define SYNT_LSARPC_V0_DS                \
00084 {                                           \
00085         {                                   \
00086                 0x3919286a, 0xb10c, 0x11d0, \
00087                 { 0x9b, 0xa8 },             \
00088                 { 0x00, 0xc0,               \
00089                   0x4f, 0xd9, 0x2e, 0xf5 }  \
00090         }, 0x00                             \
00091 }
00092 
00093 #define SYNT_SAMR_V1                        \
00094 {                                           \
00095         {                                   \
00096                 0x12345778, 0x1234, 0xabcd, \
00097                 { 0xef, 0x00 },             \
00098                 { 0x01, 0x23,               \
00099                   0x45, 0x67, 0x89, 0xac }  \
00100         }, 0x01                             \
00101 }
00102 
00103 #define SYNT_NETLOGON_V1                    \
00104 {                                           \
00105         {                                   \
00106                 0x12345678, 0x1234, 0xabcd, \
00107                 { 0xef, 0x00 },             \
00108                 { 0x01, 0x23,               \
00109                   0x45, 0x67, 0xcf, 0xfb }  \
00110         }, 0x01                             \
00111 }
00112 
00113 #define SYNT_WINREG_V1                      \
00114 {                                           \
00115         {                                   \
00116                 0x338cd001, 0x2244, 0x31f1, \
00117                 { 0xaa, 0xaa },             \
00118                 { 0x90, 0x00,               \
00119                   0x38, 0x00, 0x10, 0x03 }  \
00120         }, 0x01                             \
00121 }
00122 
00123 #define SYNT_SPOOLSS_V1                     \
00124 {                                           \
00125         {                                   \
00126                 0x12345678, 0x1234, 0xabcd, \
00127                 { 0xef, 0x00 },             \
00128                 { 0x01, 0x23,               \
00129                   0x45, 0x67, 0x89, 0xab }  \
00130         }, 0x01                             \
00131 }
00132 
00133 #define SYNT_NONE_V0                        \
00134 {                                           \
00135         {                                   \
00136                 0x0, 0x0, 0x0,              \
00137                 { 0x00, 0x00 },             \
00138                 { 0x00, 0x00,               \
00139                   0x00, 0x00, 0x00, 0x00 }  \
00140         }, 0x00                             \
00141 }
00142 
00143 #define SYNT_NETDFS_V3                      \
00144 {                                           \
00145         {                                   \
00146                 0x4fc742e0, 0x4a10, 0x11cf, \
00147                 { 0x82, 0x73 },             \
00148                 { 0x00, 0xaa,               \
00149                   0x00, 0x4a, 0xe6, 0x73 }  \
00150         }, 0x03                             \
00151 }
00152 
00153 #define SYNT_ECHO_V1                        \
00154 {                                           \
00155         {                                   \
00156                 0x60a15ec5, 0x4de8, 0x11d7, \
00157                 { 0xa6, 0x37 },             \
00158                 { 0x00, 0x50,               \
00159                   0x56, 0xa2, 0x01, 0x82 }  \
00160         }, 0x01                             \
00161 }
00162 
00163 #define SYNT_SHUTDOWN_V1                    \
00164 {                                           \
00165         {                                   \
00166                 0x894de0c0, 0x0d55, 0x11d3, \
00167                 { 0xa3, 0x22 },             \
00168                 { 0x00, 0xc0,               \
00169                   0x4f, 0xa3, 0x21, 0xa1 }  \
00170         }, 0x01                             \
00171 }
00172 
00173 #define SYNT_SVCCTL_V2                      \
00174 {                                           \
00175         {                                   \
00176                 0x367abb81, 0x9844, 0x35f1, \
00177                 { 0xad, 0x32 },             \
00178                 { 0x98, 0xf0,               \
00179                   0x38, 0x00, 0x10, 0x03 }  \
00180         }, 0x02                             \
00181 }
00182 
00183 
00184 #define SYNT_EVENTLOG_V0                    \
00185 {                                           \
00186         {                                   \
00187                 0x82273fdc, 0xe32a, 0x18c3, \
00188                 { 0x3f, 0x78 },             \
00189                 { 0x82, 0x79,               \
00190                   0x29, 0xdc, 0x23, 0xea }  \
00191         }, 0x00                             \
00192 }
00193 
00194 #define SYNT_NTSVCS_V1                      \
00195 {                                           \
00196         {                                   \
00197                 0x8d9f4e40, 0xa03d, 0x11ce, \
00198                 { 0x8f, 0x69},              \
00199                 { 0x08, 0x00,               \
00200                   0x3e, 0x30, 0x05, 0x1b }  \
00201         }, 0x01                             \
00202 }
00203 
00204 /*
00205  * IMPORTANT!!  If you update this structure, make sure to
00206  * update the index #defines in smb.h.
00207  */
00208 
00209 const struct pipe_id_info pipe_names [] =
00210 {
00211         /* client pipe , abstract syntax       , server pipe   , transfer syntax */
00212         { PIPE_LSARPC  , SYNT_LSARPC_V0        , PIPE_LSASS    , TRANS_SYNT_V2 },
00213         { PIPE_LSARPC  , SYNT_LSARPC_V0_DS     , PIPE_LSASS    , TRANS_SYNT_V2 },
00214         { PIPE_SAMR    , SYNT_SAMR_V1          , PIPE_LSASS    , TRANS_SYNT_V2 },
00215         { PIPE_NETLOGON, SYNT_NETLOGON_V1      , PIPE_LSASS    , TRANS_SYNT_V2 },
00216         { PIPE_SRVSVC  , SYNT_SRVSVC_V3        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
00217         { PIPE_WKSSVC  , SYNT_WKSSVC_V1        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
00218         { PIPE_WINREG  , SYNT_WINREG_V1        , PIPE_WINREG   , TRANS_SYNT_V2 },
00219         { PIPE_SPOOLSS , SYNT_SPOOLSS_V1       , PIPE_SPOOLSS  , TRANS_SYNT_V2 },
00220         { PIPE_NETDFS  , SYNT_NETDFS_V3        , PIPE_NETDFS   , TRANS_SYNT_V2 },
00221         { PIPE_ECHO    , SYNT_ECHO_V1          , PIPE_ECHO     , TRANS_SYNT_V2 },
00222         { PIPE_SHUTDOWN, SYNT_SHUTDOWN_V1      , PIPE_SHUTDOWN , TRANS_SYNT_V2 },
00223         { PIPE_SVCCTL  , SYNT_SVCCTL_V2        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
00224         { PIPE_EVENTLOG, SYNT_EVENTLOG_V0      , PIPE_EVENTLOG , TRANS_SYNT_V2 },
00225         { PIPE_NTSVCS  , SYNT_NTSVCS_V1        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
00226         { NULL         , SYNT_NONE_V0          , NULL          , SYNT_NONE_V0  }
00227 };
00228 
00229 /****************************************************************************
00230  Return the pipe name from the index.
00231  ****************************************************************************/
00232 
00233 const char *cli_get_pipe_name(int pipe_idx)
00234 {
00235         return &pipe_names[pipe_idx].client_pipe[5];
00236 }
00237 
00238 /*******************************************************************
00239  Inits an RPC_HDR structure.
00240 ********************************************************************/
00241 
00242 void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
00243                                 uint32 call_id, int data_len, int auth_len)
00244 {
00245         hdr->major        = 5;               /* RPC version 5 */
00246         hdr->minor        = 0;               /* minor version 0 */
00247         hdr->pkt_type     = pkt_type;        /* RPC packet type */
00248         hdr->flags        = flags;           /* dce/rpc flags */
00249         hdr->pack_type[0] = 0x10;            /* little-endian data representation */
00250         hdr->pack_type[1] = 0;               /* packed data representation */
00251         hdr->pack_type[2] = 0;               /* packed data representation */
00252         hdr->pack_type[3] = 0;               /* packed data representation */
00253         hdr->frag_len     = data_len;        /* fragment length, fill in later */
00254         hdr->auth_len     = auth_len;        /* authentication length */
00255         hdr->call_id      = call_id;         /* call identifier - match incoming RPC */
00256 }
00257 
00258 /*******************************************************************
00259  Reads or writes an RPC_HDR structure.
00260 ********************************************************************/
00261 
00262 BOOL smb_io_rpc_hdr(const char *desc,  RPC_HDR *rpc, prs_struct *ps, int depth)
00263 {
00264         if (rpc == NULL)
00265                 return False;
00266 
00267         prs_debug(ps, depth, desc, "smb_io_rpc_hdr");
00268         depth++;
00269 
00270         if(!prs_uint8 ("major     ", ps, depth, &rpc->major))
00271                 return False;
00272 
00273         if(!prs_uint8 ("minor     ", ps, depth, &rpc->minor))
00274                 return False;
00275         if(!prs_uint8 ("pkt_type  ", ps, depth, &rpc->pkt_type))
00276                 return False;
00277         if(!prs_uint8 ("flags     ", ps, depth, &rpc->flags))
00278                 return False;
00279 
00280         /* We always marshall in little endian format. */
00281         if (MARSHALLING(ps))
00282                 rpc->pack_type[0] = 0x10;
00283 
00284         if(!prs_uint8("pack_type0", ps, depth, &rpc->pack_type[0]))
00285                 return False;
00286         if(!prs_uint8("pack_type1", ps, depth, &rpc->pack_type[1]))
00287                 return False;
00288         if(!prs_uint8("pack_type2", ps, depth, &rpc->pack_type[2]))
00289                 return False;
00290         if(!prs_uint8("pack_type3", ps, depth, &rpc->pack_type[3]))
00291                 return False;
00292 
00293         /*
00294          * If reading and pack_type[0] == 0 then the data is in big-endian
00295          * format. Set the flag in the prs_struct to specify reverse-endainness.
00296          */
00297 
00298         if (UNMARSHALLING(ps) && rpc->pack_type[0] == 0) {
00299                 DEBUG(10,("smb_io_rpc_hdr: PDU data format is big-endian. Setting flag.\n"));
00300                 prs_set_endian_data(ps, RPC_BIG_ENDIAN);
00301         }
00302 
00303         if(!prs_uint16("frag_len  ", ps, depth, &rpc->frag_len))
00304                 return False;
00305         if(!prs_uint16("auth_len  ", ps, depth, &rpc->auth_len))
00306                 return False;
00307         if(!prs_uint32("call_id   ", ps, depth, &rpc->call_id))
00308                 return False;
00309         return True;
00310 }
00311 
00312 /*******************************************************************
00313  Reads or writes an RPC_IFACE structure.
00314 ********************************************************************/
00315 
00316 static BOOL smb_io_rpc_iface(const char *desc, RPC_IFACE *ifc, prs_struct *ps, int depth)
00317 {
00318         if (ifc == NULL)
00319                 return False;
00320 
00321         prs_debug(ps, depth, desc, "smb_io_rpc_iface");
00322         depth++;
00323 
00324         if (!prs_align(ps))
00325                 return False;
00326 
00327         if (!smb_io_uuid(  "uuid", &ifc->uuid, ps, depth))
00328                 return False;
00329 
00330         if(!prs_uint32 ("version", ps, depth, &ifc->version))
00331                 return False;
00332 
00333         return True;
00334 }
00335 
00336 /*******************************************************************
00337  Inits an RPC_ADDR_STR structure.
00338 ********************************************************************/
00339 
00340 static void init_rpc_addr_str(RPC_ADDR_STR *str, const char *name)
00341 {
00342         str->len = strlen(name) + 1;
00343         fstrcpy(str->str, name);
00344 }
00345 
00346 /*******************************************************************
00347  Reads or writes an RPC_ADDR_STR structure.
00348 ********************************************************************/
00349 
00350 static BOOL smb_io_rpc_addr_str(const char *desc,  RPC_ADDR_STR *str, prs_struct *ps, int depth)
00351 {
00352         if (str == NULL)
00353                 return False;
00354 
00355         prs_debug(ps, depth, desc, "smb_io_rpc_addr_str");
00356         depth++;
00357         if(!prs_align(ps))
00358                 return False;
00359 
00360         if(!prs_uint16 (      "len", ps, depth, &str->len))
00361                 return False;
00362         if(!prs_uint8s (True, "str", ps, depth, (uchar*)str->str, MIN(str->len, sizeof(str->str)) ))
00363                 return False;
00364         return True;
00365 }
00366 
00367 /*******************************************************************
00368  Inits an RPC_HDR_BBA structure.
00369 ********************************************************************/
00370 
00371 static void init_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid)
00372 {
00373         bba->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */
00374         bba->max_rsize = max_rsize; /* max receive fragment size (0x1630) */   
00375         bba->assoc_gid = assoc_gid; /* associated group id (0x0) */ 
00376 }
00377 
00378 /*******************************************************************
00379  Reads or writes an RPC_HDR_BBA structure.
00380 ********************************************************************/
00381 
00382 static BOOL smb_io_rpc_hdr_bba(const char *desc,  RPC_HDR_BBA *rpc, prs_struct *ps, int depth)
00383 {
00384         if (rpc == NULL)
00385                 return False;
00386 
00387         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_bba");
00388         depth++;
00389 
00390         if(!prs_uint16("max_tsize", ps, depth, &rpc->max_tsize))
00391                 return False;
00392         if(!prs_uint16("max_rsize", ps, depth, &rpc->max_rsize))
00393                 return False;
00394         if(!prs_uint32("assoc_gid", ps, depth, &rpc->assoc_gid))
00395                 return False;
00396         return True;
00397 }
00398 
00399 /*******************************************************************
00400  Inits an RPC_CONTEXT structure.
00401  Note the transfer pointer must remain valid until this is marshalled.
00402 ********************************************************************/
00403 
00404 void init_rpc_context(RPC_CONTEXT *rpc_ctx, uint16 context_id, RPC_IFACE *abstract, RPC_IFACE *transfer)
00405 {
00406         rpc_ctx->context_id   = context_id   ; /* presentation context identifier (0x0) */
00407         rpc_ctx->num_transfer_syntaxes = 1 ; /* the number of syntaxes (has always been 1?)(0x1) */
00408 
00409         /* num and vers. of interface client is using */
00410         rpc_ctx->abstract = *abstract;
00411 
00412         /* vers. of interface to use for replies */
00413         rpc_ctx->transfer = transfer;
00414 }
00415 
00416 /*******************************************************************
00417  Inits an RPC_HDR_RB structure.
00418  Note the context pointer must remain valid until this is marshalled.
00419 ********************************************************************/
00420 
00421 void init_rpc_hdr_rb(RPC_HDR_RB *rpc, 
00422                                 uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
00423                                 RPC_CONTEXT *context)
00424 {
00425         init_rpc_hdr_bba(&rpc->bba, max_tsize, max_rsize, assoc_gid);
00426 
00427         rpc->num_contexts = 1;
00428         rpc->rpc_context = context;
00429 }
00430 
00431 /*******************************************************************
00432  Reads or writes an RPC_CONTEXT structure.
00433 ********************************************************************/
00434 
00435 BOOL smb_io_rpc_context(const char *desc, RPC_CONTEXT *rpc_ctx, prs_struct *ps, int depth)
00436 {
00437         int i;
00438 
00439         if (rpc_ctx == NULL)
00440                 return False;
00441 
00442         if(!prs_align(ps))
00443                 return False;
00444         if(!prs_uint16("context_id  ", ps, depth, &rpc_ctx->context_id ))
00445                 return False;
00446         if(!prs_uint8 ("num_transfer_syntaxes", ps, depth, &rpc_ctx->num_transfer_syntaxes))
00447                 return False;
00448 
00449         /* num_transfer_syntaxes must not be zero. */
00450         if (rpc_ctx->num_transfer_syntaxes == 0)
00451                 return False;
00452 
00453         if(!smb_io_rpc_iface("", &rpc_ctx->abstract, ps, depth))
00454                 return False;
00455 
00456         if (UNMARSHALLING(ps)) {
00457                 if (!(rpc_ctx->transfer = PRS_ALLOC_MEM(ps, RPC_IFACE, rpc_ctx->num_transfer_syntaxes))) {
00458                         return False;
00459                 }
00460         }
00461 
00462         for (i = 0; i < rpc_ctx->num_transfer_syntaxes; i++ ) {
00463                 if (!smb_io_rpc_iface("", &rpc_ctx->transfer[i], ps, depth))
00464                         return False;
00465         }
00466         return True;
00467 } 
00468 
00469 /*******************************************************************
00470  Reads or writes an RPC_HDR_RB structure.
00471 ********************************************************************/
00472 
00473 BOOL smb_io_rpc_hdr_rb(const char *desc, RPC_HDR_RB *rpc, prs_struct *ps, int depth)
00474 {
00475         int i;
00476         
00477         if (rpc == NULL)
00478                 return False;
00479 
00480         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_rb");
00481         depth++;
00482 
00483         if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth))
00484                 return False;
00485 
00486         if(!prs_uint8("num_contexts", ps, depth, &rpc->num_contexts))
00487                 return False;
00488 
00489         /* 3 pad bytes following - will be mopped up by the prs_align in smb_io_rpc_context(). */
00490 
00491         /* num_contexts must not be zero. */
00492         if (rpc->num_contexts == 0)
00493                 return False;
00494 
00495         if (UNMARSHALLING(ps)) {
00496                 if (!(rpc->rpc_context = PRS_ALLOC_MEM(ps, RPC_CONTEXT, rpc->num_contexts))) {
00497                         return False;
00498                 }
00499         }
00500 
00501         for (i = 0; i < rpc->num_contexts; i++ ) {
00502                 if (!smb_io_rpc_context("", &rpc->rpc_context[i], ps, depth))
00503                         return False;
00504         }
00505 
00506         return True;
00507 }
00508 
00509 /*******************************************************************
00510  Inits an RPC_RESULTS structure.
00511 
00512  lkclXXXX only one reason at the moment!
00513 ********************************************************************/
00514 
00515 static void init_rpc_results(RPC_RESULTS *res, 
00516                                 uint8 num_results, uint16 result, uint16 reason)
00517 {
00518         res->num_results = num_results; /* the number of results (0x01) */
00519         res->result      = result     ;  /* result (0x00 = accept) */
00520         res->reason      = reason     ;  /* reason (0x00 = no reason specified) */
00521 }
00522 
00523 /*******************************************************************
00524  Reads or writes an RPC_RESULTS structure.
00525 
00526  lkclXXXX only one reason at the moment!
00527 ********************************************************************/
00528 
00529 static BOOL smb_io_rpc_results(const char *desc, RPC_RESULTS *res, prs_struct *ps, int depth)
00530 {
00531         if (res == NULL)
00532                 return False;
00533 
00534         prs_debug(ps, depth, desc, "smb_io_rpc_results");
00535         depth++;
00536 
00537         if(!prs_align(ps))
00538                 return False;
00539         
00540         if(!prs_uint8 ("num_results", ps, depth, &res->num_results))    
00541                 return False;
00542 
00543         if(!prs_align(ps))
00544                 return False;
00545         
00546         if(!prs_uint16("result     ", ps, depth, &res->result))
00547                 return False;
00548         if(!prs_uint16("reason     ", ps, depth, &res->reason))
00549                 return False;
00550         return True;
00551 }
00552 
00553 /*******************************************************************
00554  Init an RPC_HDR_BA structure.
00555 
00556  lkclXXXX only one reason at the moment!
00557 
00558 ********************************************************************/
00559 
00560 void init_rpc_hdr_ba(RPC_HDR_BA *rpc, 
00561                                 uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
00562                                 const char *pipe_addr,
00563                                 uint8 num_results, uint16 result, uint16 reason,
00564                                 RPC_IFACE *transfer)
00565 {
00566         init_rpc_hdr_bba (&rpc->bba, max_tsize, max_rsize, assoc_gid);
00567         init_rpc_addr_str(&rpc->addr, pipe_addr);
00568         init_rpc_results (&rpc->res, num_results, result, reason);
00569 
00570         /* the transfer syntax from the request */
00571         memcpy(&rpc->transfer, transfer, sizeof(rpc->transfer));
00572 }
00573 
00574 /*******************************************************************
00575  Reads or writes an RPC_HDR_BA structure.
00576 ********************************************************************/
00577 
00578 BOOL smb_io_rpc_hdr_ba(const char *desc, RPC_HDR_BA *rpc, prs_struct *ps, int depth)
00579 {
00580         if (rpc == NULL)
00581                 return False;
00582 
00583         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_ba");
00584         depth++;
00585 
00586         if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth))
00587                 return False;
00588         if(!smb_io_rpc_addr_str("", &rpc->addr, ps, depth))
00589                 return False;
00590         if(!smb_io_rpc_results("", &rpc->res, ps, depth))
00591                 return False;
00592         if(!smb_io_rpc_iface("", &rpc->transfer, ps, depth))
00593                 return False;
00594         return True;
00595 }
00596 
00597 /*******************************************************************
00598  Init an RPC_HDR_REQ structure.
00599 ********************************************************************/
00600 
00601 void init_rpc_hdr_req(RPC_HDR_REQ *hdr, uint32 alloc_hint, uint16 opnum)
00602 {
00603         hdr->alloc_hint   = alloc_hint; /* allocation hint */
00604         hdr->context_id   = 0;         /* presentation context identifier */
00605         hdr->opnum        = opnum;     /* opnum */
00606 }
00607 
00608 /*******************************************************************
00609  Reads or writes an RPC_HDR_REQ structure.
00610 ********************************************************************/
00611 
00612 BOOL smb_io_rpc_hdr_req(const char *desc, RPC_HDR_REQ *rpc, prs_struct *ps, int depth)
00613 {
00614         if (rpc == NULL)
00615                 return False;
00616 
00617         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_req");
00618         depth++;
00619 
00620         if(!prs_uint32("alloc_hint", ps, depth, &rpc->alloc_hint))
00621                 return False;
00622         if(!prs_uint16("context_id", ps, depth, &rpc->context_id))
00623                 return False;
00624         if(!prs_uint16("opnum     ", ps, depth, &rpc->opnum))
00625                 return False;
00626         return True;
00627 }
00628 
00629 /*******************************************************************
00630  Reads or writes an RPC_HDR_RESP structure.
00631 ********************************************************************/
00632 
00633 BOOL smb_io_rpc_hdr_resp(const char *desc, RPC_HDR_RESP *rpc, prs_struct *ps, int depth)
00634 {
00635         if (rpc == NULL)
00636                 return False;
00637 
00638         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_resp");
00639         depth++;
00640 
00641         if(!prs_uint32("alloc_hint", ps, depth, &rpc->alloc_hint))
00642                 return False;
00643         if(!prs_uint16("context_id", ps, depth, &rpc->context_id))
00644                 return False;
00645         if(!prs_uint8 ("cancel_ct ", ps, depth, &rpc->cancel_count))
00646                 return False;
00647         if(!prs_uint8 ("reserved  ", ps, depth, &rpc->reserved))
00648                 return False;
00649         return True;
00650 }
00651 
00652 /*******************************************************************
00653  Reads or writes an RPC_HDR_FAULT structure.
00654 ********************************************************************/
00655 
00656 BOOL smb_io_rpc_hdr_fault(const char *desc, RPC_HDR_FAULT *rpc, prs_struct *ps, int depth)
00657 {
00658         if (rpc == NULL)
00659                 return False;
00660 
00661         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_fault");
00662         depth++;
00663 
00664         if(!prs_dcerpc_status("status  ", ps, depth, &rpc->status))
00665                 return False;
00666         if(!prs_uint32("reserved", ps, depth, &rpc->reserved))
00667                 return False;
00668 
00669     return True;
00670 }
00671 
00672 /*******************************************************************
00673  Inits an RPC_HDR_AUTH structure.
00674 ********************************************************************/
00675 
00676 void init_rpc_hdr_auth(RPC_HDR_AUTH *rai,
00677                                 uint8 auth_type, uint8 auth_level,
00678                                 uint8 auth_pad_len,
00679                                 uint32 auth_context_id)
00680 {
00681         rai->auth_type     = auth_type;
00682         rai->auth_level    = auth_level;
00683         rai->auth_pad_len  = auth_pad_len;
00684         rai->auth_reserved = 0;
00685         rai->auth_context_id = auth_context_id;
00686 }
00687 
00688 /*******************************************************************
00689  Reads or writes an RPC_HDR_AUTH structure.
00690 ********************************************************************/
00691 
00692 BOOL smb_io_rpc_hdr_auth(const char *desc, RPC_HDR_AUTH *rai, prs_struct *ps, int depth)
00693 {
00694         if (rai == NULL)
00695                 return False;
00696 
00697         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_auth");
00698         depth++;
00699 
00700         if(!prs_align(ps))
00701                 return False;
00702 
00703         if(!prs_uint8 ("auth_type    ", ps, depth, &rai->auth_type))
00704                 return False;
00705         if(!prs_uint8 ("auth_level   ", ps, depth, &rai->auth_level))
00706                 return False;
00707         if(!prs_uint8 ("auth_pad_len ", ps, depth, &rai->auth_pad_len))
00708                 return False;
00709         if(!prs_uint8 ("auth_reserved", ps, depth, &rai->auth_reserved))
00710                 return False;
00711         if(!prs_uint32("auth_context_id", ps, depth, &rai->auth_context_id))
00712                 return False;
00713 
00714         return True;
00715 }
00716 
00717 /*******************************************************************
00718  Checks an RPC_AUTH_VERIFIER structure.
00719 ********************************************************************/
00720 
00721 BOOL rpc_auth_verifier_chk(RPC_AUTH_VERIFIER *rav,
00722                                 const char *signature, uint32 msg_type)
00723 {
00724         return (strequal(rav->signature, signature) && rav->msg_type == msg_type);
00725 }
00726 
00727 /*******************************************************************
00728  Inits an RPC_AUTH_VERIFIER structure.
00729 ********************************************************************/
00730 
00731 void init_rpc_auth_verifier(RPC_AUTH_VERIFIER *rav,
00732                                 const char *signature, uint32 msg_type)
00733 {
00734         fstrcpy(rav->signature, signature); /* "NTLMSSP" */
00735         rav->msg_type = msg_type; /* NTLMSSP_MESSAGE_TYPE */
00736 }
00737 
00738 /*******************************************************************
00739  Reads or writes an RPC_AUTH_VERIFIER structure.
00740 ********************************************************************/
00741 
00742 BOOL smb_io_rpc_auth_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth)
00743 {
00744         if (rav == NULL)
00745                 return False;
00746 
00747         prs_debug(ps, depth, desc, "smb_io_rpc_auth_verifier");
00748         depth++;
00749 
00750         /* "NTLMSSP" */
00751         if(!prs_string("signature", ps, depth, rav->signature,
00752                         sizeof(rav->signature)))
00753                 return False;
00754         if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type)) /* NTLMSSP_MESSAGE_TYPE */
00755                 return False;
00756 
00757         return True;
00758 }
00759 
00760 /*******************************************************************
00761  This parses an RPC_AUTH_VERIFIER for schannel. I think
00762 ********************************************************************/
00763 
00764 BOOL smb_io_rpc_schannel_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth)
00765 {
00766         if (rav == NULL)
00767                 return False;
00768 
00769         prs_debug(ps, depth, desc, "smb_io_rpc_schannel_verifier");
00770         depth++;
00771 
00772         if(!prs_string("signature", ps, depth, rav->signature, sizeof(rav->signature)))
00773                 return False;
00774         if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type))
00775                 return False;
00776 
00777         return True;
00778 }
00779 
00780 /*******************************************************************
00781 creates an RPC_AUTH_SCHANNEL_NEG structure.
00782 ********************************************************************/
00783 
00784 void init_rpc_auth_schannel_neg(RPC_AUTH_SCHANNEL_NEG *neg,
00785                               const char *domain, const char *myname)
00786 {
00787         neg->type1 = 0;
00788         neg->type2 = 0x3;
00789         fstrcpy(neg->domain, domain);
00790         fstrcpy(neg->myname, myname);
00791 }
00792 
00793 /*******************************************************************
00794  Reads or writes an RPC_AUTH_SCHANNEL_NEG structure.
00795 ********************************************************************/
00796 
00797 BOOL smb_io_rpc_auth_schannel_neg(const char *desc, RPC_AUTH_SCHANNEL_NEG *neg,
00798                                 prs_struct *ps, int depth)
00799 {
00800         if (neg == NULL)
00801                 return False;
00802 
00803         prs_debug(ps, depth, desc, "smb_io_rpc_auth_schannel_neg");
00804         depth++;
00805 
00806         if(!prs_align(ps))
00807                 return False;
00808 
00809         if(!prs_uint32("type1", ps, depth, &neg->type1))
00810                 return False;
00811         if(!prs_uint32("type2", ps, depth, &neg->type2))
00812                 return False;
00813         if(!prs_string("domain  ", ps, depth, neg->domain, sizeof(neg->domain)))
00814                 return False;
00815         if(!prs_string("myname  ", ps, depth, neg->myname, sizeof(neg->myname)))
00816                 return False;
00817 
00818         return True;
00819 }
00820 
00821 /*******************************************************************
00822 reads or writes an RPC_AUTH_SCHANNEL_CHK structure.
00823 ********************************************************************/
00824 
00825 BOOL smb_io_rpc_auth_schannel_chk(const char *desc, int auth_len, 
00826                                 RPC_AUTH_SCHANNEL_CHK * chk,
00827                                 prs_struct *ps, int depth)
00828 {
00829         if (chk == NULL)
00830                 return False;
00831 
00832         prs_debug(ps, depth, desc, "smb_io_rpc_auth_schannel_chk");
00833         depth++;
00834 
00835         if ( !prs_uint8s(False, "sig  ", ps, depth, chk->sig, sizeof(chk->sig)) )
00836                 return False;
00837                 
00838         if ( !prs_uint8s(False, "seq_num", ps, depth, chk->seq_num, sizeof(chk->seq_num)) )
00839                 return False;
00840                 
00841         if ( !prs_uint8s(False, "packet_digest", ps, depth, chk->packet_digest, sizeof(chk->packet_digest)) )
00842                 return False;
00843         
00844         if ( auth_len == RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN ) {
00845                 if ( !prs_uint8s(False, "confounder", ps, depth, chk->confounder, sizeof(chk->confounder)) )
00846                         return False;
00847         }
00848 
00849         return True;
00850 }

Sambaに対してSat Aug 29 21:23:17 2009に生成されました。  doxygen 1.4.7