Print this page
1575 untangle libmlrpc ... (libmlrpc)

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libmlrpc/common/libmlrpc.h
          +++ new/usr/src/lib/libmlrpc/common/libmlrpc.h
↓ open down ↓ 20 lines elided ↑ open up ↑
  21   21  /*
  22   22   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
  25   25  
  26   26  #ifndef _LIBMLRPC_H
  27   27  #define _LIBMLRPC_H
  28   28  
  29   29  #include <sys/types.h>
  30   30  #include <sys/uio.h>
  31      -#include <smbsrv/wintypes.h>
  32      -#include <smbsrv/ndr.h>
  33      -#include <smbsrv/smb_sid.h>
  34      -#include <smbsrv/smb_xdr.h>
  35   31  
       32 +#include <smb/wintypes.h>
       33 +#include <libmlrpc/ndr.h>
       34 +
  36   35  #ifdef  __cplusplus
  37   36  extern "C" {
  38   37  #endif
  39   38  
  40   39  /*
  41   40   * An MSRPC compatible implementation of OSF DCE RPC.  DCE RPC is derived
  42   41   * from the Apollo Network Computing Architecture (NCA) RPC implementation.
  43   42   *
  44   43   * CAE Specification (1997)
  45   44   * DCE 1.1: Remote Procedure Call
↓ open down ↓ 196 lines elided ↑ open up ↑
 242  241  /*
 243  242   * The binding list space must be provided by the application library
 244  243   * for use by the underlying RPC library.  We need at least two binding
 245  244   * slots per connection.
 246  245   */
 247  246  #define NDR_N_BINDING_POOL      2
 248  247  
 249  248  typedef struct ndr_pipe {
 250  249          void                    *np_listener;
 251  250          const char              *np_endpoint;
 252      -        smb_netuserinfo_t       *np_user;
      251 +        struct smb_netuserinfo  *np_user;
 253  252          int                     (*np_send)(struct ndr_pipe *, void *, size_t);
 254  253          int                     (*np_recv)(struct ndr_pipe *, void *, size_t);
 255  254          int                     np_fid;
 256  255          uint16_t                np_max_xmit_frag;
 257  256          uint16_t                np_max_recv_frag;
 258  257          ndr_binding_t           *np_binding;
 259  258          ndr_binding_t           np_binding_pool[NDR_N_BINDING_POOL];
 260  259  } ndr_pipe_t;
 261  260  
 262  261  /*
↓ open down ↓ 132 lines elided ↑ open up ↑
 395  394  } ndr_vcb_t;
 396  395  
 397  396  typedef struct ndr_vcbuf {
 398  397          uint16_t len;
 399  398          uint16_t size;
 400  399          ndr_vcb_t *vcb;
 401  400  } ndr_vcbuf_t;
 402  401  
 403  402  ndr_heap_t *ndr_heap_create(void);
 404  403  void ndr_heap_destroy(ndr_heap_t *);
      404 +void *ndr_heap_dupmem(ndr_heap_t *, const void *, size_t);
 405  405  void *ndr_heap_malloc(ndr_heap_t *, unsigned);
 406  406  void *ndr_heap_strdup(ndr_heap_t *, const char *);
 407  407  int ndr_heap_mstring(ndr_heap_t *, const char *, ndr_mstring_t *);
 408  408  void ndr_heap_mkvcs(ndr_heap_t *, char *, ndr_vcstr_t *);
 409  409  void ndr_heap_mkvcb(ndr_heap_t *, uint8_t *, uint32_t, ndr_vcbuf_t *);
 410      -smb_sid_t *ndr_heap_siddup(ndr_heap_t *, smb_sid_t *);
 411  410  int ndr_heap_used(ndr_heap_t *);
 412  411  int ndr_heap_avail(ndr_heap_t *);
 413  412  
 414  413  #define NDR_MALLOC(XA, SZ)      ndr_heap_malloc((XA)->heap, SZ)
 415  414  #define NDR_NEW(XA, T)          ndr_heap_malloc((XA)->heap, sizeof (T))
 416  415  #define NDR_NEWN(XA, T, N)      ndr_heap_malloc((XA)->heap, sizeof (T)*(N))
 417  416  #define NDR_STRDUP(XA, S)       ndr_heap_strdup((XA)->heap, (S))
 418  417  #define NDR_MSTRING(XA, S, OUT) ndr_heap_mstring((XA)->heap, (S), (OUT))
 419      -#define NDR_SIDDUP(XA, S)       ndr_heap_siddup((XA)->heap, (S))
      418 +#define NDR_SIDDUP(XA, S)       ndr_heap_dupmem((XA)->heap, (S), smb_sid_len(S))
 420  419  
 421  420  typedef struct ndr_xa {
 422  421          unsigned short          ptype;          /* high bits special */
 423  422          unsigned short          opnum;
 424  423          ndr_stream_t            recv_nds;
 425  424          ndr_hdr_t               recv_hdr;
 426  425          ndr_stream_t            send_nds;
 427  426          ndr_hdr_t               send_hdr;
 428  427          ndr_binding_t           *binding;       /* what we're using */
 429  428          ndr_binding_t           *binding_list;  /* from connection */
↓ open down ↓ 51 lines elided ↑ open up ↑
 481  480          ndr_heap_t              *nb_heap;
 482  481          ndr_typeinfo_t          *nb_ti;
 483  482  } ndr_buf_t;
 484  483  
 485  484  /* ndr_ops.c */
 486  485  int nds_initialize(ndr_stream_t *, unsigned, int, ndr_heap_t *);
 487  486  void nds_destruct(ndr_stream_t *);
 488  487  void nds_show_state(ndr_stream_t *);
 489  488  
 490  489  /* ndr_client.c */
 491      -int ndr_clnt_bind(ndr_client_t *, const char *, ndr_binding_t **);
      490 +int ndr_clnt_bind(ndr_client_t *, ndr_service_t *, ndr_binding_t **);
 492  491  int ndr_clnt_call(ndr_binding_t *, int, void *);
 493  492  void ndr_clnt_free_heap(ndr_client_t *);
 494  493  
 495  494  /* ndr_marshal.c */
 496  495  ndr_buf_t *ndr_buf_init(ndr_typeinfo_t *);
 497  496  void ndr_buf_fini(ndr_buf_t *);
 498  497  int ndr_buf_decode(ndr_buf_t *, unsigned, unsigned, const char *data, size_t,
 499  498      void *);
 500  499  int ndr_decode_call(ndr_xa_t *, void *);
 501  500  int ndr_encode_return(ndr_xa_t *, void *);
↓ open down ↓ 5 lines elided ↑ open up ↑
 507  506  void ndr_remove_frag_hdr(ndr_stream_t *);
 508  507  void ndr_show_hdr(ndr_common_header_t *);
 509  508  unsigned ndr_bind_ack_hdr_size(ndr_xa_t *);
 510  509  unsigned ndr_alter_context_rsp_hdr_size(void);
 511  510  
 512  511  /* ndr_server.c */
 513  512  void ndr_pipe_worker(ndr_pipe_t *);
 514  513  
 515  514  int ndr_generic_call_stub(ndr_xa_t *);
 516  515  
 517      -boolean_t ndr_is_admin(ndr_xa_t *);
 518      -boolean_t ndr_is_poweruser(ndr_xa_t *);
 519      -int32_t ndr_native_os(ndr_xa_t *);
 520      -
 521  516  /* ndr_svc.c */
 522  517  ndr_stub_table_t *ndr_svc_find_stub(ndr_service_t *, int);
 523  518  ndr_service_t *ndr_svc_lookup_name(const char *);
 524  519  ndr_service_t *ndr_svc_lookup_uuid(ndr_uuid_t *, int, ndr_uuid_t *, int);
 525  520  int ndr_svc_register(ndr_service_t *);
 526  521  void ndr_svc_unregister(ndr_service_t *);
 527  522  void ndr_svc_binding_pool_init(ndr_binding_t **, ndr_binding_t pool[], int);
 528  523  ndr_binding_t *ndr_svc_find_binding(ndr_xa_t *, ndr_p_context_id_t);
 529  524  ndr_binding_t *ndr_svc_new_binding(ndr_xa_t *);
 530  525  
 531  526  int ndr_uuid_parse(char *, ndr_uuid_t *);
 532  527  void ndr_uuid_unparse(ndr_uuid_t *, char *);
 533  528  
 534  529  ndr_hdid_t *ndr_hdalloc(const ndr_xa_t *, const void *);
 535  530  void ndr_hdfree(const ndr_xa_t *, const ndr_hdid_t *);
 536  531  ndr_handle_t *ndr_hdlookup(const ndr_xa_t *, const ndr_hdid_t *);
 537  532  void ndr_hdclose(ndr_pipe_t *);
 538  533  
 539  534  ssize_t ndr_uiomove(caddr_t, size_t, enum uio_rw, struct uio *);
 540  535  
      536 +/*
      537 + * An ndr_client_t is created while binding a client connection to hold
      538 + * the context for calls made using that connection.
      539 + *
      540 + * Handles are RPC call specific and we use an inheritance mechanism to
      541 + * ensure that each handle has a pointer to the client_t.  When the top
      542 + * level (bind) handle is released, we close the connection.
      543 + *
      544 + * There are some places in libmlsvc where the code assumes that the
      545 + * handle member is first in this struct.  careful
      546 + */
      547 +typedef struct mlrpc_handle {
      548 +        ndr_hdid_t      handle;         /* keep first */
      549 +        ndr_client_t    *clnt;
      550 +} mlrpc_handle_t;
      551 +
      552 +int mlrpc_clh_create(mlrpc_handle_t *, void *);
      553 +uint32_t mlrpc_clh_bind(mlrpc_handle_t *, ndr_service_t *);
      554 +void mlrpc_clh_unbind(mlrpc_handle_t *);
      555 +void *mlrpc_clh_free(mlrpc_handle_t *);
      556 +
      557 +int ndr_rpc_call(mlrpc_handle_t *, int, void *);
      558 +int ndr_rpc_get_ssnkey(mlrpc_handle_t *, unsigned char *, size_t);
      559 +void *ndr_rpc_malloc(mlrpc_handle_t *, size_t);
      560 +ndr_heap_t *ndr_rpc_get_heap(mlrpc_handle_t *);
      561 +void ndr_rpc_release(mlrpc_handle_t *);
      562 +void ndr_rpc_set_nonull(mlrpc_handle_t *);
      563 +
      564 +boolean_t ndr_is_null_handle(mlrpc_handle_t *);
      565 +boolean_t ndr_is_bind_handle(mlrpc_handle_t *);
      566 +void ndr_inherit_handle(mlrpc_handle_t *, mlrpc_handle_t *);
      567 +
 541  568  #ifdef  __cplusplus
 542  569  }
 543  570  #endif
 544  571  
 545  572  #endif  /* _LIBMLRPC_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX