Add the strlen to push to smb_bytes_push_str, return the converted size
[metze/samba/wip.git] / source3 / include / proto.h
index 212bbf0df76f5fe6b25aa9561fb65c59c77bc5dd..e00d644852a070bdda0e8b91b043aef4a4b54360 100644 (file)
@@ -441,7 +441,7 @@ int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr);
 int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v);
 bool dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
                         uint32_t *val);
-bool dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v);
+int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v);
 uint32_t dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
                                     uint32_t *oldval, uint32_t change_val);
 int32 dbwrap_change_int32_atomic(struct db_context *db, const char *keystr,
@@ -501,46 +501,6 @@ void display_set_stderr(void);
 NTSTATUS map_nt_error_from_unix(int unix_error);
 int map_errno_from_nt_status(NTSTATUS status);
 
-/* The following definitions come from lib/events.c  */
-
-struct timed_event *event_add_timed(struct event_context *event_ctx,
-                               TALLOC_CTX *mem_ctx,
-                               struct timeval when,
-                               const char *event_name,
-                               void (*handler)(struct event_context *event_ctx,
-                                               struct timed_event *te,
-                                               const struct timeval *now,
-                                               void *private_data),
-                               void *private_data);
-struct fd_event *event_add_fd(struct event_context *event_ctx,
-                             TALLOC_CTX *mem_ctx,
-                             int fd, uint16_t flags,
-                             void (*handler)(struct event_context *event_ctx,
-                                             struct fd_event *event,
-                                             uint16 flags,
-                                             void *private_data),
-                             void *private_data);
-void event_fd_set_writeable(struct fd_event *fde);
-void event_fd_set_not_writeable(struct fd_event *fde);
-void event_fd_set_readable(struct fd_event *fde);
-void event_fd_set_not_readable(struct fd_event *fde);
-bool event_add_to_select_args(struct event_context *event_ctx,
-                             const struct timeval *now,
-                             fd_set *read_fds, fd_set *write_fds,
-                             struct timeval *timeout, int *maxfd);
-bool events_pending(struct event_context *event_ctx);
-bool run_events(struct event_context *event_ctx,
-               int selrtn, fd_set *read_fds, fd_set *write_fds);
-struct timeval *get_timed_events_timeout(struct event_context *event_ctx,
-                                        struct timeval *to_ret);
-int event_loop_once(struct event_context *ev);
-struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
-int set_event_dispatch_time(struct event_context *event_ctx,
-                           const char *event_name, struct timeval when);
-int cancel_named_event(struct event_context *event_ctx,
-                      const char *event_name);
-void dump_event_list(struct event_context *event_ctx);
-
 /* The following definitions come from lib/fault.c  */
 void fault_setup(void (*fn)(void *));
 void dump_core_setup(const char *progname);
@@ -841,7 +801,7 @@ bool set_remote_machine_name(const char *remote_name, bool perm);
 const char *get_remote_machine_name(void);
 void sub_set_smb_name(const char *name);
 void set_current_user_info(const char *smb_name, const char *unix_name,
-                          const char *full_name, const char *domain);
+                          const char *domain);
 const char *get_current_username(void);
 void standard_sub_basic(const char *smb_name, const char *domain_name,
                        char *str, size_t len);
@@ -969,6 +929,7 @@ void *sys_memalign( size_t align, size_t size );
 int sys_usleep(long usecs);
 ssize_t sys_read(int fd, void *buf, size_t count);
 ssize_t sys_write(int fd, const void *buf, size_t count);
+ssize_t sys_writev(int fd, const struct iovec *iov, int iovcnt);
 ssize_t sys_pread(int fd, void *buf, size_t count, SMB_OFF_T off);
 ssize_t sys_pwrite(int fd, const void *buf, size_t count, SMB_OFF_T off);
 ssize_t sys_send(int s, const void *msg, size_t len, int flags);
@@ -1164,7 +1125,6 @@ struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
 bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_info);
 bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid,
                             gid_t **gids, size_t *num_gids);
-const char *get_numlist(const char *p, uint32 **num, int *count);
 bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf);
 bool socket_exist(const char *fname);
 bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st);
@@ -1183,6 +1143,7 @@ int set_blocking(int fd, bool set);
 void smb_msleep(unsigned int t);
 void become_daemon(bool Fork, bool no_process_group);
 bool reinit_after_fork(struct messaging_context *msg_ctx,
+                      struct event_context *ev_ctx,
                       bool parent_longlived);
 bool yesno(const char *p);
 void *malloc_(size_t size);
@@ -1229,10 +1190,10 @@ char *lib_path(const char *name);
 char *modules_path(const char *name);
 char *data_path(const char *name);
 char *state_path(const char *name);
+char *cache_path(const char *name);
 const char *shlib_ext(void);
-char *parent_dirname(const char *path);
-bool parent_dirname_talloc(TALLOC_CTX *mem_ctx, const char *dir,
-                          char **parent, const char **name);
+bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
+                   const char **name);
 bool ms_has_wild(const char *s);
 bool ms_has_wild_w(const smb_ucs2_t *s);
 bool mask_match(const char *string, const char *pattern, bool is_case_sensitive);
@@ -1440,6 +1401,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
                                  size_t *size_ret);
 NTSTATUS read_data(int fd, char *buffer, size_t N);
 ssize_t write_data(int fd, const char *buffer, size_t N);
+ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt);
 bool send_keepalive(int client);
 NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
                                          unsigned int timeout,
@@ -1457,10 +1419,21 @@ int open_socket_in(int type,
                int dlevel,
                const struct sockaddr_storage *psock,
                bool rebind);
-int open_socket_out(int type,
-               const struct sockaddr_storage *pss,
-               uint16_t port,
-               int timeout);
+NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
+                        int timeout, int *pfd);
+struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
+                                      struct event_context *ev,
+                                      const struct sockaddr_storage *pss,
+                                      uint16_t port,
+                                      int timeout);
+NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd);
+struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
+                                            struct event_context *ev,
+                                            struct timeval wait_time,
+                                            const struct sockaddr_storage *pss,
+                                            uint16_t port,
+                                            int timeout);
+NTSTATUS open_socket_out_defer_recv(struct async_req *req, int *pfd);
 bool open_any_socket_out(struct sockaddr_storage *addrs, int num_addrs,
                         int timeout, int *fd_index, int *fd);
 int open_udp_socket(const char *host, int port);
@@ -2307,19 +2280,6 @@ _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool
 _PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss);
 const char *ndr_errstr(enum ndr_err_code err);
 
-/* The following definitions come from librpc/ndr/ndr_sec_helper.c  */
-
-size_t ndr_size_dom_sid(const struct dom_sid *sid, int flags);
-size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags);
-size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags);
-size_t ndr_size_security_ace(const struct security_ace *ace, int flags);
-size_t ndr_size_security_acl(const struct security_acl *acl, int flags);
-size_t ndr_size_security_descriptor(const struct security_descriptor *sd, int flags);
-void ndr_print_dom_sid(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
-void ndr_print_dom_sid2(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
-void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
-void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
-
 /* The following definitions come from librpc/ndr/sid.c  */
 
 char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
@@ -2329,14 +2289,18 @@ char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
 const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
 _PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b);
 _PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out);
-_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax);
+_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor,
+                                           struct ndr_syntax_id *syntax);
 const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
-_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower);
+_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(const struct epm_tower *tower);
+_PUBLIC_ const char *derpc_transport_string_by_transport(enum dcerpc_transport_t t);
 _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 
                                   struct epm_tower *tower, 
                                   struct dcerpc_binding **b_out);
-_PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower);
+_PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx,
+                                            const struct dcerpc_binding *binding,
+                                            struct epm_tower *tower);
 
 /* The following definitions come from librpc/rpc/dcerpc.c  */
 
@@ -2419,7 +2383,10 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
                                const char *server,
                                const char *share,
                                bool show_hdr,
-                               bool force_encrypt);
+                               bool force_encrypt,
+                               int max_protocol,
+                               int port,
+                               int name_type);
 void cli_cm_shutdown(void);
 void cli_cm_display(void);
 void cli_cm_set_credentials(struct user_auth_info *auth_info);
@@ -2470,7 +2437,7 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx,
 
 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
-int cli_set_port(struct cli_state *cli, int port);
+void cli_set_port(struct cli_state *cli, int port);
 bool cli_receive_smb(struct cli_state *cli);
 ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len);
 bool cli_receive_smb_readX_header(struct cli_state *cli);
@@ -2495,6 +2462,7 @@ struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
                                DATA_BLOB data);
 NTSTATUS cli_echo_recv(struct async_req *req);
 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
+bool cli_ucs2(struct cli_state *cli);
 
 /* The following definitions come from libsmb/clierror.c  */
 
@@ -2533,7 +2501,8 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname,
                 uint32 CreateDisposition, uint32 CreateOptions,
                 uint8 SecuityFlags);
 int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess);
-uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str);
+uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
+                           size_t strlen, size_t *pconverted_size);
 struct async_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
                                struct cli_state *cli,
                                const char *fname, int flags, int share_mode);
@@ -2666,12 +2635,6 @@ void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, bool _verbose, bool _numeric, voi
 
 /* The following definitions come from libsmb/clirap.c  */
 
-bool cli_api_pipe(struct cli_state *cli, const char *pipe_name,
-                  uint16 *setup, uint32 setup_count, uint32 max_setup_count,
-                  char *params, uint32 param_count, uint32 max_param_count,
-                  char *data, uint32 data_count, uint32 max_data_count,
-                  char **rparam, uint32 *rparam_count,
-                  char **rdata, uint32 *rdata_count);
 bool cli_api(struct cli_state *cli,
             char *param, int prcnt, int mprcnt,
             char *data, int drcnt, int mdrcnt,
@@ -2800,6 +2763,25 @@ ssize_t cli_write(struct cli_state *cli,
                 const char *buf, off_t offset, size_t size);
 ssize_t cli_smbwrite(struct cli_state *cli,
                     int fnum, char *buf, off_t offset, size_t size1);
+struct async_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
+                                     struct event_context *ev,
+                                     struct cli_state *cli, uint16_t fnum,
+                                     uint16_t mode, const uint8_t *buf,
+                                     off_t offset, size_t size);
+NTSTATUS cli_write_andx_recv(struct async_req *req, size_t *pwritten);
+
+struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+                               struct cli_state *cli,
+                               uint16_t fnum, uint16_t mode,
+                               off_t start_offset, size_t window_size,
+                               size_t (*source)(uint8_t *buf, size_t n,
+                                                void *priv),
+                               void *priv);
+NTSTATUS cli_push_recv(struct async_req *req);
+NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
+                 off_t start_offset, size_t window_size,
+                 size_t (*source)(uint8_t *buf, size_t n, void *priv),
+                 void *priv);
 
 /* The following definitions come from libsmb/clisecdesc.c  */
 
@@ -2845,7 +2827,7 @@ size_t clistr_push_fn(const char *function,
                        int flags);
 size_t clistr_pull_fn(const char *function,
                        unsigned int line,
-                       struct cli_state *cli,
+                       const char *inbuf,
                        char *dest,
                        const void *src,
                        int dest_len,
@@ -2854,7 +2836,7 @@ size_t clistr_pull_fn(const char *function,
 size_t clistr_pull_talloc_fn(const char *function,
                                unsigned int line,
                                TALLOC_CTX *ctx,
-                               struct cli_state *cli,
+                               const char *inbuf,
                                char **pp_dest,
                                const void *src,
                                int src_len,
@@ -2964,7 +2946,6 @@ NTSTATUS map_nt_error_from_gss(uint32 gss_maj, uint32 minor);
 /* The following definitions come from libsmb/namecache.c  */
 
 bool namecache_enable(void);
-bool namecache_shutdown(void);
 bool namecache_store(const char *name,
                        int name_type,
                        int num_names,
@@ -3896,6 +3877,8 @@ char *lp_addprinter_cmd(void);
 char *lp_deleteprinter_cmd(void);
 char *lp_os2_driver_map(void);
 char *lp_lockdir(void);
+char *lp_statedir(void);
+char *lp_cachedir(void);
 char *lp_piddir(void);
 char *lp_mangling_method(void);
 int lp_mangle_prefix(void);
@@ -4419,8 +4402,9 @@ NTSTATUS local_password_change(const char *user_name,
                                const char *new_passwd, 
                                char **pp_err_str,
                                char **pp_msg_str);
-bool init_sam_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 buflen);
-uint32 init_buffer_from_sam_v3 (uint8 **buf, struct samu *sampass, bool size_only);
+bool init_samu_from_buffer(struct samu *sampass, uint32_t level,
+                          uint8 *buf, uint32 buflen);
+uint32 init_buffer_from_samu (uint8 **buf, struct samu *sampass, bool size_only);
 bool pdb_copy_sam_account(struct samu *dst, struct samu *src );
 bool pdb_update_bad_password_count(struct samu *sampass, bool *updated);
 bool pdb_update_autolock_flag(struct samu *sampass, bool *updated);
@@ -4739,7 +4723,6 @@ bool parse_lpq_entry(enum printing_types printing_type,char *line,
 /* The following definitions come from printing/notify.c  */
 
 int print_queue_snum(const char *qname);
-bool print_notify_messages_pending(void);
 void print_notify_send_messages(struct messaging_context *msg_ctx,
                                unsigned int timeout);
 void notify_printer_status_byname(const char *sharename, uint32 status);
@@ -4762,7 +4745,6 @@ void notify_printer_printername(int snum, char *printername);
 void notify_printer_port(int snum, char *port_name);
 void notify_printer_location(int snum, char *location);
 void notify_printer_byname( const char *printername, uint32 change, const char *value );
-bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t *p_num_pids, pid_t **pp_pid_list);
 
 /* The following definitions come from printing/nt_printing.c  */
 
@@ -4874,7 +4856,8 @@ bool sysv_cache_reload(void);
 
 NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn,
                        const char *fname,
-                       uint16_t current_vuid, files_struct *fsp);
+                       uint16_t current_vuid, files_struct *fsp,
+                       SMB_STRUCT_STAT *psbuf);
 void print_fsp_end(files_struct *fsp, enum file_close_type close_type);
 
 /* The following definitions come from printing/printing.c  */
@@ -5213,16 +5196,27 @@ NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli,
 
 /* The following definitions come from rpc_client/cli_pipe.c  */
 
-NTSTATUS rpc_api_pipe_req(struct rpc_pipe_client *cli,
+struct async_req *rpc_api_pipe_req_send(TALLOC_CTX *mem_ctx,
+                                       struct event_context *ev,
+                                       struct rpc_pipe_client *cli,
+                                       uint8_t op_num,
+                                       prs_struct *req_data);
+NTSTATUS rpc_api_pipe_req_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
+                              prs_struct *reply_pdu);
+NTSTATUS rpc_api_pipe_req(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli,
                        uint8 op_num,
                        prs_struct *in_data,
                        prs_struct *out_data);
+struct async_req *rpc_pipe_bind_send(TALLOC_CTX *mem_ctx,
+                                    struct event_context *ev,
+                                    struct rpc_pipe_client *cli,
+                                    struct cli_pipe_auth_data *auth);
+NTSTATUS rpc_pipe_bind_recv(struct async_req *req);
 NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
                       struct cli_pipe_auth_data *auth);
 unsigned int rpccli_set_timeout(struct rpc_pipe_client *cli,
                                unsigned int timeout);
 bool rpccli_get_pwd_hash(struct rpc_pipe_client *cli, uint8_t nt_hash[16]);
-struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
 NTSTATUS rpccli_anon_bind_data(TALLOC_CTX *mem_ctx,
                               struct cli_pipe_auth_data **presult);
 NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx,
@@ -5248,6 +5242,10 @@ NTSTATUS rpc_pipe_open_tcp(TALLOC_CTX *mem_ctx, const char *host,
 NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
                               const struct ndr_syntax_id *abstract_syntax,
                               struct rpc_pipe_client **presult);
+NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *abstract_syntax, 
+                               NTSTATUS (*dispatch) (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r),
+                               struct auth_serversupplied_info *serversupplied_info,
+                               struct rpc_pipe_client **presult);
 NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
                                  const struct ndr_syntax_id *interface,
                                  struct rpc_pipe_client **presult);
@@ -5298,6 +5296,17 @@ NTSTATUS cli_get_session_key(TALLOC_CTX *mem_ctx,
                             struct rpc_pipe_client *cli,
                             DATA_BLOB *session_key);
 
+/* The following definitions come from rpc_client/rpc_transport_np.c  */
+
+NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+                              const struct ndr_syntax_id *abstract_syntax,
+                              struct rpc_cli_transport **presult);
+struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
+
+/* The following definitions come from rpc_client/rpc_transport_sock.c  */
+
+NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
+                                struct rpc_cli_transport **presult);
 
 /* The following definitions come from rpc_client/cli_reg.c  */
 
@@ -5468,39 +5477,12 @@ WERROR rpccli_spoolss_rffpcnex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
                            const char *localmachine, uint32 printerlocal,
                            SPOOL_NOTIFY_OPTION *option);
 
-/* The following definitions come from rpc_client/cli_svcctl.c  */
-
-WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
-                                      POLICY_HND *hSCM, uint32 type, uint32 state, 
-                                     uint32 *returned, ENUM_SERVICES_STATUS **service_array  );
-
 /* The following definitions come from rpc_client/init_lsa.c  */
 
 void init_lsa_String(struct lsa_String *name, const char *s);
 void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s);
 void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s);
 void init_lsa_AsciiStringLarge(struct lsa_AsciiStringLarge *name, const char *s);
-void init_lsa_sec_qos(struct lsa_QosInfo *r,
-                     uint32_t len,
-                     uint16_t impersonation_level,
-                     uint8_t context_mode,
-                     uint8_t effective_only);
-void init_lsa_obj_attr(struct lsa_ObjectAttribute *r,
-                      uint32_t len,
-                      uint8_t *root_dir,
-                      const char *object_name,
-                      uint32_t attributes,
-                      struct security_descriptor *sec_desc,
-                      struct lsa_QosInfo *sec_qos);
-void init_lsa_translated_sid(struct lsa_TranslatedSid *r,
-                            enum lsa_SidType sid_type,
-                            uint32_t rid,
-                            uint32_t sid_index);
-void init_lsa_translated_name2(struct lsa_TranslatedName2 *r,
-                              enum lsa_SidType sid_type,
-                              const char *name,
-                              uint32_t sid_index,
-                              uint32_t unknown);
 
 /* The following definitions come from rpc_client/init_netlogon.c  */
 
@@ -5592,189 +5574,6 @@ void init_netr_CryptPassword(const char *pwd,
 
 /* The following definitions come from rpc_client/init_samr.c  */
 
-void init_samr_DomInfo1(struct samr_DomInfo1 *r,
-                       uint16_t min_password_length,
-                       uint16_t password_history_length,
-                       uint32_t password_properties,
-                       int64_t max_password_age,
-                       int64_t min_password_age);
-void init_samr_DomGeneralInformation(struct samr_DomGeneralInformation *r,
-                                    NTTIME force_logoff_time,
-                                    const char *oem_information,
-                                    const char *domain_name,
-                                    const char *primary,
-                                    uint64_t sequence_num,
-                                    enum samr_DomainServerState domain_server_state,
-                                    enum samr_Role role,
-                                    uint32_t unknown3,
-                                    uint32_t num_users,
-                                    uint32_t num_groups,
-                                    uint32_t num_aliases);
-void init_samr_DomInfo3(struct samr_DomInfo3 *r,
-                       NTTIME force_logoff_time);
-void init_samr_DomOEMInformation(struct samr_DomOEMInformation *r,
-                                const char *oem_information);
-void init_samr_DomInfo5(struct samr_DomInfo5 *r,
-                       const char *domain_name);
-void init_samr_DomInfo6(struct samr_DomInfo6 *r,
-                       const char *primary);
-void init_samr_DomInfo7(struct samr_DomInfo7 *r,
-                       enum samr_Role role);
-void init_samr_DomInfo8(struct samr_DomInfo8 *r,
-                       uint64_t sequence_num,
-                       NTTIME domain_create_time);
-void init_samr_DomInfo9(struct samr_DomInfo9 *r,
-                        enum samr_DomainServerState domain_server_state);
-void init_samr_DomInfo12(struct samr_DomInfo12 *r,
-                        uint64_t lockout_duration,
-                        uint64_t lockout_window,
-                        uint16_t lockout_threshold);
-void init_samr_group_info1(struct samr_GroupInfoAll *r,
-                          const char *name,
-                          uint32_t attributes,
-                          uint32_t num_members,
-                          const char *description);
-void init_samr_group_info2(struct lsa_String *r, const char *group_name);
-void init_samr_group_info3(struct samr_GroupInfoAttributes *r,
-                          uint32_t attributes);
-void init_samr_group_info4(struct lsa_String *r, const char *description);
-void init_samr_group_info5(struct samr_GroupInfoAll *r,
-                          const char *name,
-                          uint32_t attributes,
-                          uint32_t num_members,
-                          const char *description);
-void init_samr_alias_info1(struct samr_AliasInfoAll *r,
-                          const char *name,
-                          uint32_t num_members,
-                          const char *description);
-void init_samr_alias_info3(struct lsa_String *r,
-                          const char *description);
-void init_samr_user_info5(struct samr_UserInfo5 *r,
-                         const char *account_name,
-                         const char *full_name,
-                         uint32_t rid,
-                         uint32_t primary_gid,
-                         const char *home_directory,
-                         const char *home_drive,
-                         const char *logon_script,
-                         const char *profile_path,
-                         const char *description,
-                         const char *workstations,
-                         NTTIME last_logon,
-                         NTTIME last_logoff,
-                         struct samr_LogonHours logon_hours,
-                         uint16_t bad_password_count,
-                         uint16_t logon_count,
-                         NTTIME last_password_change,
-                         NTTIME acct_expiry,
-                         uint32_t acct_flags);
-void init_samr_user_info7(struct samr_UserInfo7 *r,
-                         const char *account_name);
-void init_samr_user_info9(struct samr_UserInfo9 *r,
-                         uint32_t primary_gid);
-void init_samr_user_info16(struct samr_UserInfo16 *r,
-                          uint32_t acct_flags);
-void init_samr_user_info18(struct samr_UserInfo18 *r,
-                          const uint8 lm_pwd[16],
-                          const uint8 nt_pwd[16],
-                          uint8_t password_expired);
-void init_samr_user_info20(struct samr_UserInfo20 *r,
-                          struct lsa_BinaryString *parameters);
-void init_samr_user_info21(struct samr_UserInfo21 *r,
-                          NTTIME last_logon,
-                          NTTIME last_logoff,
-                          NTTIME last_password_change,
-                          NTTIME acct_expiry,
-                          NTTIME allow_password_change,
-                          NTTIME force_password_change,
-                          const char *account_name,
-                          const char *full_name,
-                          const char *home_directory,
-                          const char *home_drive,
-                          const char *logon_script,
-                          const char *profile_path,
-                          const char *description,
-                          const char *workstations,
-                          const char *comment,
-                          struct lsa_BinaryString *parameters,
-                          uint32_t rid,
-                          uint32_t primary_gid,
-                          uint32_t acct_flags,
-                          uint32_t fields_present,
-                          struct samr_LogonHours logon_hours,
-                          uint16_t bad_password_count,
-                          uint16_t logon_count,
-                          uint16_t country_code,
-                          uint16_t code_page,
-                          uint8_t nt_password_set,
-                          uint8_t lm_password_set,
-                          uint8_t password_expired);
-void init_samr_user_info23(struct samr_UserInfo23 *r,
-                          NTTIME last_logon,
-                          NTTIME last_logoff,
-                          NTTIME last_password_change,
-                          NTTIME acct_expiry,
-                          NTTIME allow_password_change,
-                          NTTIME force_password_change,
-                          const char *account_name,
-                          const char *full_name,
-                          const char *home_directory,
-                          const char *home_drive,
-                          const char *logon_script,
-                          const char *profile_path,
-                          const char *description,
-                          const char *workstations,
-                          const char *comment,
-                          struct lsa_BinaryString *parameters,
-                          uint32_t rid,
-                          uint32_t primary_gid,
-                          uint32_t acct_flags,
-                          uint32_t fields_present,
-                          struct samr_LogonHours logon_hours,
-                          uint16_t bad_password_count,
-                          uint16_t logon_count,
-                          uint16_t country_code,
-                          uint16_t code_page,
-                          uint8_t nt_password_set,
-                          uint8_t lm_password_set,
-                          uint8_t password_expired,
-                          struct samr_CryptPassword *pwd_buf);
-void init_samr_user_info24(struct samr_UserInfo24 *r,
-                          struct samr_CryptPassword *pwd_buf,
-                          uint8_t password_expired);
-void init_samr_user_info25(struct samr_UserInfo25 *r,
-                          NTTIME last_logon,
-                          NTTIME last_logoff,
-                          NTTIME last_password_change,
-                          NTTIME acct_expiry,
-                          NTTIME allow_password_change,
-                          NTTIME force_password_change,
-                          const char *account_name,
-                          const char *full_name,
-                          const char *home_directory,
-                          const char *home_drive,
-                          const char *logon_script,
-                          const char *profile_path,
-                          const char *description,
-                          const char *workstations,
-                          const char *comment,
-                          struct lsa_BinaryString *parameters,
-                          uint32_t rid,
-                          uint32_t primary_gid,
-                          uint32_t acct_flags,
-                          uint32_t fields_present,
-                          struct samr_LogonHours logon_hours,
-                          uint16_t bad_password_count,
-                          uint16_t logon_count,
-                          uint16_t country_code,
-                          uint16_t code_page,
-                          uint8_t nt_password_set,
-                          uint8_t lm_password_set,
-                          uint8_t password_expired,
-                          struct samr_CryptPasswordEx *pwd_buf);
-void init_samr_user_info26(struct samr_UserInfo26 *r,
-                          struct samr_CryptPasswordEx *pwd_buf,
-                          uint8_t password_expired);
 void init_samr_CryptPasswordEx(const char *pwd,
                               DATA_BLOB *session_key,
                               struct samr_CryptPasswordEx *pwd_buf);
@@ -5782,134 +5581,6 @@ void init_samr_CryptPassword(const char *pwd,
                             DATA_BLOB *session_key,
                             struct samr_CryptPassword *pwd_buf);
 
-/* The following definitions come from rpc_client/init_srvsvc.c  */
-
-void init_srvsvc_NetSrvInfo102(struct srvsvc_NetSrvInfo102 *r,
-                              enum srvsvc_PlatformId platform_id,
-                              const char *server_name,
-                              uint32_t version_major,
-                              uint32_t version_minor,
-                              uint32_t server_type,
-                              const char *comment,
-                              uint32_t users,
-                              uint32_t disc,
-                              uint32_t hidden,
-                              uint32_t announce,
-                              uint32_t anndelta,
-                              uint32_t licenses,
-                              const char *userpath);
-void init_srvsvc_NetSrvInfo101(struct srvsvc_NetSrvInfo101 *r,
-                              enum srvsvc_PlatformId platform_id,
-                              const char *server_name,
-                              uint32_t version_major,
-                              uint32_t version_minor,
-                              uint32_t server_type,
-                              const char *comment);
-void init_srvsvc_NetSrvInfo100(struct srvsvc_NetSrvInfo100 *r,
-                              enum srvsvc_PlatformId platform_id,
-                              const char *server_name);
-void init_srvsvc_NetShareInfo0(struct srvsvc_NetShareInfo0 *r,
-                              const char *name);
-void init_srvsvc_NetShareInfo1(struct srvsvc_NetShareInfo1 *r,
-                              const char *name,
-                              enum srvsvc_ShareType type,
-                              const char *comment);
-void init_srvsvc_NetShareInfo2(struct srvsvc_NetShareInfo2 *r,
-                              const char *name,
-                              enum srvsvc_ShareType type,
-                              const char *comment,
-                              uint32_t permissions,
-                              uint32_t max_users,
-                              uint32_t current_users,
-                              const char *path,
-                              const char *password);
-void init_srvsvc_NetShareInfo501(struct srvsvc_NetShareInfo501 *r,
-                                const char *name,
-                                enum srvsvc_ShareType type,
-                                const char *comment,
-                                uint32_t csc_policy);
-void init_srvsvc_NetShareInfo502(struct srvsvc_NetShareInfo502 *r,
-                                const char *name,
-                                enum srvsvc_ShareType type,
-                                const char *comment,
-                                uint32_t permissions,
-                                uint32_t max_users,
-                                uint32_t current_users,
-                                const char *path,
-                                const char *password,
-                                struct sec_desc_buf *sd_buf);
-void init_srvsvc_NetShareInfo1004(struct srvsvc_NetShareInfo1004 *r,
-                                 const char *comment);
-void init_srvsvc_NetShareInfo1005(struct srvsvc_NetShareInfo1005 *r,
-                                 uint32_t dfs_flags);
-void init_srvsvc_NetShareInfo1006(struct srvsvc_NetShareInfo1006 *r,
-                                 uint32_t max_users);
-void init_srvsvc_NetShareInfo1007(struct srvsvc_NetShareInfo1007 *r,
-                                 uint32_t flags,
-                                 const char *alternate_directory_name);
-void init_srvsvc_NetRemoteTODInfo(struct srvsvc_NetRemoteTODInfo *r,
-                                 uint32_t elapsed,
-                                 uint32_t msecs,
-                                 uint32_t hours,
-                                 uint32_t mins,
-                                 uint32_t secs,
-                                 uint32_t hunds,
-                                 int32_t ttimezone,
-                                 uint32_t tinterval,
-                                 uint32_t day,
-                                 uint32_t month,
-                                 uint32_t year,
-                                 uint32_t weekday);
-void init_srvsvc_NetSessInfo0(struct srvsvc_NetSessInfo0 *r,
-                             const char *client);
-void init_srvsvc_NetSessInfo1(struct srvsvc_NetSessInfo1 *r,
-                             const char *client,
-                             const char *user,
-                             uint32_t num_open,
-                             uint32_t _time,
-                             uint32_t idle_time,
-                             uint32_t user_flags);
-void init_srvsvc_NetSessInfo2(struct srvsvc_NetSessInfo2 *r,
-                             const char *client,
-                             const char *user,
-                             uint32_t num_open,
-                             uint32_t _time,
-                             uint32_t idle_time,
-                             uint32_t user_flags,
-                             const char *client_type);
-void init_srvsvc_NetSessInfo10(struct srvsvc_NetSessInfo10 *r,
-                              const char *client,
-                              const char *user,
-                              uint32_t _time,
-                              uint32_t idle_time);
-void init_srvsvc_NetSessInfo502(struct srvsvc_NetSessInfo502 *r,
-                              const char *client,
-                              const char *user,
-                              uint32_t num_open,
-                              uint32_t _time,
-                              uint32_t idle_time,
-                              uint32_t user_flags,
-                              const char *client_type,
-                              const char *transport);
-void init_srvsvc_NetFileInfo2(struct srvsvc_NetFileInfo2 *r,
-                             uint32_t fid);
-void init_srvsvc_NetFileInfo3(struct srvsvc_NetFileInfo3 *r,
-                             uint32_t fid,
-                             uint32_t permissions,
-                             uint32_t num_locks,
-                             const char *path,
-                             const char *user);
-void init_srvsvc_NetConnInfo0(struct srvsvc_NetConnInfo0 *r,
-                             uint32_t conn_id);
-void init_srvsvc_NetConnInfo1(struct srvsvc_NetConnInfo1 *r,
-                             uint32_t conn_id,
-                             uint32_t conn_type,
-                             uint32_t num_open,
-                             uint32_t num_users,
-                             uint32_t conn_time,
-                             const char *user,
-                             const char *share);
-
 /* The following definitions come from rpc_client/ndr.c  */
 
 NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
@@ -5919,7 +5590,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
 
 /* The following definitions come from rpc_parse/parse_buffer.c  */
 
-void rpcbuf_init(RPC_BUFFER *buffer, uint32 size, TALLOC_CTX *ctx);
+bool rpcbuf_init(RPC_BUFFER *buffer, uint32 size, TALLOC_CTX *ctx);
 bool prs_rpcbuffer(const char *desc, prs_struct *ps, int depth, RPC_BUFFER *buffer);
 bool prs_rpcbuffer_p(const char *desc, prs_struct *ps, int depth, RPC_BUFFER **buffer);
 bool rpcbuf_alloc_size(RPC_BUFFER *buffer, uint32 buffer_size);
@@ -6109,7 +5780,6 @@ bool prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
 /* The following definitions come from rpc_parse/parse_rpc.c  */
 
 const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx,
-                                        struct cli_state *cli,
                                         const struct ndr_syntax_id *interface);
 void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
                                uint32 call_id, int data_len, int auth_len);
@@ -6503,23 +6173,6 @@ bool spoolss_io_r_xcvdataport(const char *desc, SPOOL_R_XCVDATAPORT *r_u, prs_st
 bool make_monitorui_buf( RPC_BUFFER *buf, const char *dllname );
 bool convert_port_data_1( NT_PORT_DATA_1 *port1, RPC_BUFFER *buf ) ;
 
-/* The following definitions come from rpc_parse/parse_svcctl.c  */
-
-bool svcctl_io_enum_services_status( const char *desc, ENUM_SERVICES_STATUS *enum_status, RPC_BUFFER *buffer, int depth );
-bool svcctl_io_service_status_process( const char *desc, SERVICE_STATUS_PROCESS *status, RPC_BUFFER *buffer, int depth );
-uint32 svcctl_sizeof_enum_services_status( ENUM_SERVICES_STATUS *status );
-bool svcctl_io_q_enum_services_status(const char *desc, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, prs_struct *ps, int depth);
-bool svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_STATUS *r_u, prs_struct *ps, int depth);
-bool svcctl_io_q_query_service_config2(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, prs_struct *ps, int depth);
-void init_service_description_buffer(SERVICE_DESCRIPTION *desc, const char *service_desc );
-bool svcctl_io_service_description( const char *desc, SERVICE_DESCRIPTION *description, RPC_BUFFER *buffer, int depth );
-uint32 svcctl_sizeof_service_description( SERVICE_DESCRIPTION *desc );
-bool svcctl_io_service_fa( const char *desc, SERVICE_FAILURE_ACTIONS *fa, RPC_BUFFER *buffer, int depth );
-uint32 svcctl_sizeof_service_fa( SERVICE_FAILURE_ACTIONS *fa);
-bool svcctl_io_r_query_service_config2(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u, prs_struct *ps, int depth);
-bool svcctl_io_q_query_service_status_ex(const char *desc, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, prs_struct *ps, int depth);
-bool svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u, prs_struct *ps, int depth);
-
 /* The following definitions come from rpc_server/srv_eventlog.c  */
 
 NTSTATUS rpc_eventlog2_init(void);
@@ -6547,7 +6200,7 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p,
 /* The following definitions come from rpc_server/srv_lsa_hnd.c  */
 
 bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name);
-bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *), void *data_ptr);
+bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void *data_ptr);
 bool find_policy_by_hnd(pipes_struct *p, POLICY_HND *hnd, void **data_p);
 bool close_policy_hnd(pipes_struct *p, POLICY_HND *hnd);
 void close_policy_by_pipe(pipes_struct *p);
@@ -6565,6 +6218,10 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
                                    const char *srv,
                                    const struct ndr_syntax_id *interface,
                                    const struct api_struct *cmds, int size);
+NTSTATUS rpc_srv_register(int version, const char *clnt,
+                         const char *srv,
+                         const struct ndr_interface_table *iface,
+                         const struct api_struct *cmds, int size);
 bool is_known_pipename(const char *cli_filename);
 bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p);
 bool api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p);
@@ -6578,14 +6235,15 @@ bool api_pipe_request(pipes_struct *p);
 
 pipes_struct *get_first_internal_pipe(void);
 pipes_struct *get_next_internal_pipe(pipes_struct *p);
-void init_rpc_pipe_hnd(void);
 
 bool fsp_is_np(struct files_struct *fsp);
-NTSTATUS np_open(struct smb_request *smb_req, const char *name,
-                struct files_struct **pfsp);
-NTSTATUS np_write(struct files_struct *fsp, const uint8_t *data, size_t len,
-                 ssize_t *nwritten);
-NTSTATUS np_read(struct files_struct *fsp, uint8_t *data, size_t len,
+NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
+                const char *client_address,
+                struct auth_serversupplied_info *server_info,
+                struct fake_file_handle **phandle);
+NTSTATUS np_write(struct fake_file_handle *handle, const uint8_t *data,
+                 size_t len, ssize_t *nwritten);
+NTSTATUS np_read(struct fake_file_handle *handle, uint8_t *data, size_t len,
                 ssize_t *nread, bool *is_data_outstanding);
 
 /* The following definitions come from rpc_server/srv_samr_util.c  */
@@ -6749,17 +6407,9 @@ WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_X
 
 char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
 
-/* The following definitions come from rpc_server/srv_svcctl.c  */
-
-void svcctl2_get_pipe_fns( struct api_struct **fns, int *n_fns );
-NTSTATUS rpc_svcctl2_init(void);
-
 /* The following definitions come from rpc_server/srv_svcctl_nt.c  */
 
 bool init_service_op_table( void );
-WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u);
-WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u );
-WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u );
 
 /* The following definitions come from rpcclient/cmd_dfs.c  */
 
@@ -6827,8 +6477,6 @@ REGVAL_CTR *svcctl_fetch_regvalues( const char *name, NT_USER_TOKEN *token );
 
 /* The following definitions come from smbd/aio.c  */
 
-void aio_request_done(uint16_t mid);
-bool aio_finished(void);
 void initialize_async_io_handler(void);
 bool schedule_aio_read_and_X(connection_struct *conn,
                             struct smb_request *req,
@@ -6839,23 +6487,9 @@ bool schedule_aio_write_and_X(connection_struct *conn,
                              files_struct *fsp, char *data,
                              SMB_OFF_T startpos,
                              size_t numtowrite);
-int process_aio_queue(void);
 int wait_for_aio_completion(files_struct *fsp);
 void cancel_aio_by_fsp(files_struct *fsp);
-bool aio_finished(void);
-void initialize_async_io_handler(void);
-int process_aio_queue(void);
-bool schedule_aio_read_and_X(connection_struct *conn,
-                            struct smb_request *req,
-                            files_struct *fsp, SMB_OFF_T startpos,
-                            size_t smb_maxcnt);
-bool schedule_aio_write_and_X(connection_struct *conn,
-                             struct smb_request *req,
-                             files_struct *fsp, char *data,
-                             SMB_OFF_T startpos,
-                             size_t numtowrite);
-void cancel_aio_by_fsp(files_struct *fsp);
-int wait_for_aio_completion(files_struct *fsp);
+void smbd_aio_complete_mid(unsigned int mid);
 
 /* The following definitions come from smbd/blocking.c  */
 
@@ -6912,6 +6546,7 @@ void msg_close_file(struct messaging_context *msg_ctx,
                    uint32_t msg_type,
                    struct server_id server_id,
                    DATA_BLOB *data);
+NTSTATUS delete_all_streams(connection_struct *conn, const char *fname);
 
 /* The following definitions come from smbd/conn.c  */
 
@@ -7018,14 +6653,9 @@ uint32 dmapi_file_flags(const char * const path);
 
 /* The following definitions come from smbd/dnsregister.c  */
 
-void dns_register_close(struct dns_reg_state **dns_state_ptr);
-void dns_register_smbd(struct dns_reg_state ** dns_state_ptr,
-               unsigned port,
-               int *maxfd,
-               fd_set *listen_set,
-               struct timeval *timeout);
-bool dns_register_smbd_reply(struct dns_reg_state *dns_state,
-               fd_set *lfds, struct timeval *timeout);
+bool smbd_setup_mdns_registration(struct tevent_context *ev,
+                                 TALLOC_CTX *mem_ctx,
+                                 uint16_t port);
 
 /* The following definitions come from smbd/dosmode.c  */
 
@@ -7038,7 +6668,8 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
                     uint32 dosmode, SMB_STRUCT_STAT *st,
                     const char *parent_dir,
                     bool newfile);
-int file_ntimes(connection_struct *conn, const char *fname, const struct timespec ts[2]);
+int file_ntimes(connection_struct *conn, const char *fname,
+               struct smb_file_time *ft);
 bool set_sticky_write_time_path(connection_struct *conn, const char *fname,
                         struct file_id fileid, const struct timespec mtime);
 bool set_sticky_write_time_fsp(struct files_struct *fsp, const struct timespec mtime);
@@ -7175,12 +6806,12 @@ bool name_to_8_3(const char *in,
 
 /* The following definitions come from smbd/mangle_hash.c  */
 
-struct mangle_fns *mangle_hash_init(void);
+const struct mangle_fns *mangle_hash_init(void);
 
 /* The following definitions come from smbd/mangle_hash2.c  */
 
-struct mangle_fns *mangle_hash2_init(void);
-struct mangle_fns *posix_mangle_init(void);
+const struct mangle_fns *mangle_hash2_init(void);
+const struct mangle_fns *posix_mangle_init(void);
 
 /* The following definitions come from smbd/map_username.c  */
 
@@ -7384,13 +7015,11 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
 /* The following definitions come from smbd/oplock.c  */
 
 int32 get_number_of_exclusive_open_oplocks(void);
-bool oplock_message_waiting(fd_set *fds);
-void process_kernel_oplocks(struct messaging_context *msg_ctx, fd_set *pfds);
+void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
 bool set_file_oplock(files_struct *fsp, int oplock_type);
 void release_file_oplock(files_struct *fsp);
 bool remove_oplock(files_struct *fsp);
 bool downgrade_oplock(files_struct *fsp);
-int oplock_notify_fd(void);
 void reply_to_oplock_break_requests(files_struct *fsp);
 void release_level_2_oplocks_on_change(files_struct *fsp);
 void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e);
@@ -7399,14 +7028,14 @@ bool init_oplocks(struct messaging_context *msg_ctx);
 
 /* The following definitions come from smbd/oplock_irix.c  */
 
-struct kernel_oplocks *irix_init_kernel_oplocks(void) ;
+struct kernel_oplocks *irix_init_kernel_oplocks(TALLOC_CTX *mem_ctx) ;
 
 /* The following definitions come from smbd/oplock_linux.c  */
 
 void linux_set_lease_capability(void);
 int linux_set_lease_sighandler(int fd);
 int linux_setlease(int fd, int leasetype);
-struct kernel_oplocks *linux_init_kernel_oplocks(void) ;
+struct kernel_oplocks *linux_init_kernel_oplocks(TALLOC_CTX *mem_ctx) ;
 
 /* The following definitions come from smbd/password.c  */
 
@@ -7430,6 +7059,8 @@ bool authorise_login(int snum, fstring user, DATA_BLOB password,
 
 /* The following definitions come from smbd/pipes.c  */
 
+NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
+                     struct files_struct **pfsp);
 void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req);
 void reply_pipe_write(struct smb_request *req);
 void reply_pipe_write_and_X(struct smb_request *req);
@@ -7463,6 +7094,8 @@ SEC_DESC *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname);
 
 /* The following definitions come from smbd/process.c  */
 
+void smbd_setup_sig_term_handler(void);
+void smbd_setup_sig_hup_handler(void);
 bool srv_send_smb(int fd, char *buffer, bool do_encrypt);
 int srv_set_message(char *buf,
                         int num_words,
@@ -7488,14 +7121,12 @@ struct idle_event *event_add_idle(struct event_context *event_ctx,
                                                  void *private_data),
                                  void *private_data);
 NTSTATUS allow_new_trans(struct trans_state *list, int mid);
-void respond_to_all_remaining_local_messages(void);
-bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
-                  uint8_t num_words, uint32_t num_bytes);
 void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes);
 const char *smb_fn_name(int type);
 void add_to_common_flags2(uint32 v);
 void remove_from_common_flags2(uint32 v);
 void construct_reply_common_req(struct smb_request *req, char *outbuf);
+size_t req_wct_ofs(struct smb_request *req);
 void chain_reply(struct smb_request *req);
 void check_reload(time_t t);
 void smbd_process(void);
@@ -7670,7 +7301,6 @@ void init_sec_ctx(void);
 
 int smbd_server_fd(void);
 int get_client_fd(void);
-int client_get_tcp_info(struct sockaddr_in *server, struct sockaddr_in *client);
 struct event_context *smbd_event_context(void);
 struct messaging_context *smbd_messaging_context(void);
 struct memcache *smbd_memcache(void);
@@ -7774,7 +7404,7 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
                           files_struct *fsp,
                           const char *fname,
                           const SMB_STRUCT_STAT *psbuf,
-                          struct timespec ts[2],
+                          struct smb_file_time *ft,
                           bool setting_write_time);
 void reply_findclose(struct smb_request *req);
 void reply_findnclose(struct smb_request *req);
@@ -7965,4 +7595,14 @@ NTSTATUS idmap_sid_to_gid(const char *domname, DOM_SID *sid, gid_t *gid);
 
 NTSTATUS nss_info_template_init( void );
 
+/* Misc protos */
+
+struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+                               struct wb_context *wb_ctx, bool need_priv,
+                               const struct winbindd_request *wb_req);
+NTSTATUS wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
+                      struct winbindd_response **presponse);
+struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx);
+
+
 #endif /*  _PROTO_H_  */