c8b79278ea62959f6ce4c50393c123d5e4988d8e
[ira/wip.git] / source3 / include / proto.h
1 /*
2  * Unix SMB/CIFS implementation.
3  * collected prototypes header
4  *
5  * frozen from "make proto" in May 2008
6  *
7  * Copyright (C) Michael Adam 2008
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef _PROTO_H_
24 #define _PROTO_H_
25
26
27 /* The following definitions come from auth/auth.c  */
28
29 NTSTATUS smb_register_auth(int version, const char *name, auth_init_function init);
30 bool load_auth_module(struct auth_context *auth_context, 
31                       const char *module, auth_methods **ret) ;
32 NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) ;
33 NTSTATUS make_auth_context_fixed(struct auth_context **auth_context, uchar chal[8]) ;
34
35 /* The following definitions come from auth/auth_builtin.c  */
36
37 NTSTATUS auth_builtin_init(void);
38
39 /* The following definitions come from auth/auth_compat.c  */
40
41 NTSTATUS check_plaintext_password(const char *smb_name, DATA_BLOB plaintext_password, auth_serversupplied_info **server_info);
42 bool password_ok(const char *smb_name, DATA_BLOB password_blob);
43
44 /* The following definitions come from auth/auth_domain.c  */
45
46 void attempt_machine_password_change(void);
47 NTSTATUS auth_domain_init(void);
48
49 NTSTATUS auth_netlogond_init(void);
50
51 /* The following definitions come from auth/auth_ntlmssp.c  */
52
53 NTSTATUS auth_ntlmssp_start(AUTH_NTLMSSP_STATE **auth_ntlmssp_state);
54 void auth_ntlmssp_end(AUTH_NTLMSSP_STATE **auth_ntlmssp_state);
55 NTSTATUS auth_ntlmssp_update(AUTH_NTLMSSP_STATE *auth_ntlmssp_state, 
56                              const DATA_BLOB request, DATA_BLOB *reply) ;
57
58 /* The following definitions come from auth/auth_sam.c  */
59
60 NTSTATUS auth_sam_init(void);
61
62 /* The following definitions come from auth/auth_server.c  */
63
64 NTSTATUS auth_server_init(void);
65
66 /* The following definitions come from auth/auth_unix.c  */
67
68 NTSTATUS auth_unix_init(void);
69
70 /* The following definitions come from auth/auth_util.c  */
71
72 NTSTATUS make_user_info_map(auth_usersupplied_info **user_info, 
73                             const char *smb_name, 
74                             const char *client_domain, 
75                             const char *wksta_name, 
76                             DATA_BLOB *lm_pwd, DATA_BLOB *nt_pwd,
77                             DATA_BLOB *lm_interactive_pwd, DATA_BLOB *nt_interactive_pwd,
78                             DATA_BLOB *plaintext, 
79                             bool encrypted);
80 bool make_user_info_netlogon_network(auth_usersupplied_info **user_info, 
81                                      const char *smb_name, 
82                                      const char *client_domain, 
83                                      const char *wksta_name, 
84                                      uint32 logon_parameters,
85                                      const uchar *lm_network_pwd,
86                                      int lm_pwd_len,
87                                      const uchar *nt_network_pwd,
88                                      int nt_pwd_len);
89 bool make_user_info_netlogon_interactive(auth_usersupplied_info **user_info, 
90                                          const char *smb_name, 
91                                          const char *client_domain, 
92                                          const char *wksta_name, 
93                                          uint32 logon_parameters,
94                                          const uchar chal[8], 
95                                          const uchar lm_interactive_pwd[16], 
96                                          const uchar nt_interactive_pwd[16], 
97                                          const uchar *dc_sess_key);
98 bool make_user_info_for_reply(auth_usersupplied_info **user_info, 
99                               const char *smb_name, 
100                               const char *client_domain,
101                               const uint8 chal[8],
102                               DATA_BLOB plaintext_password);
103 NTSTATUS make_user_info_for_reply_enc(auth_usersupplied_info **user_info, 
104                                       const char *smb_name,
105                                       const char *client_domain, 
106                                       DATA_BLOB lm_resp, DATA_BLOB nt_resp);
107 bool make_user_info_guest(auth_usersupplied_info **user_info) ;
108 NTSTATUS make_server_info_sam(auth_serversupplied_info **server_info, 
109                               struct samu *sampass);
110 NTSTATUS create_local_token(auth_serversupplied_info *server_info);
111 NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
112                                     bool is_guest,
113                                     uid_t *uid, gid_t *gid,
114                                     char **found_username,
115                                     struct nt_user_token **token);
116 bool user_in_group_sid(const char *username, const DOM_SID *group_sid);
117 bool user_in_group(const char *username, const char *groupname);
118 NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info, 
119                              char *unix_username,
120                              struct passwd *pwd);
121 NTSTATUS make_serverinfo_from_username(TALLOC_CTX *mem_ctx,
122                                        const char *username,
123                                        bool is_guest,
124                                        struct auth_serversupplied_info **presult);
125 struct auth_serversupplied_info *copy_serverinfo(TALLOC_CTX *mem_ctx,
126                                                  const auth_serversupplied_info *src);
127 bool init_guest_info(void);
128 bool server_info_set_session_key(struct auth_serversupplied_info *info,
129                                  DATA_BLOB session_key);
130 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
131                                 auth_serversupplied_info **server_info);
132 bool copy_current_user(struct current_user *dst, struct current_user *src);
133 struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, char *domuser,
134                              fstring save_username, bool create );
135 NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, 
136                                 const char *sent_nt_username,
137                                 const char *domain,
138                                 auth_serversupplied_info **server_info, 
139                                 struct netr_SamInfo3 *info3);
140 NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
141                                           const char *sent_nt_username,
142                                           const char *domain,
143                                           const struct wbcAuthUserInfo *info,
144                                           auth_serversupplied_info **server_info);
145 void free_user_info(auth_usersupplied_info **user_info);
146 bool make_auth_methods(struct auth_context *auth_context, auth_methods **auth_method) ;
147 bool is_trusted_domain(const char* dom_name);
148
149 /* The following definitions come from auth/auth_winbind.c  */
150
151 NTSTATUS auth_winbind_init(void);
152
153 /* The following definitions come from auth/auth_wbc.c  */
154
155 NTSTATUS auth_wbc_init(void);
156
157 /* The following definitions come from auth/pampass.c  */
158
159 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
160 bool smb_pam_close_session(char *user, char *tty, char *rhost);
161 NTSTATUS smb_pam_accountcheck(const char * user);
162 NTSTATUS smb_pam_passcheck(const char * user, const char * password);
163 bool smb_pam_passchange(const char * user, const char * oldpassword, const char * newpassword);
164 NTSTATUS smb_pam_accountcheck(const char * user);
165 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
166 bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
167
168 /* The following definitions come from auth/pass_check.c  */
169
170 void dfs_unlogin(void);
171 NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *password, 
172                     int pwlen, bool (*fn) (const char *, const char *), bool run_cracker);
173
174 /* The following definitions come from auth/token_util.c  */
175
176 bool nt_token_check_sid ( const DOM_SID *sid, const NT_USER_TOKEN *token );
177 bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid );
178 NT_USER_TOKEN *get_root_nt_token( void );
179 NTSTATUS add_aliases(const DOM_SID *domain_sid,
180                      struct nt_user_token *token);
181 NTSTATUS create_builtin_users(const DOM_SID *sid);
182 NTSTATUS create_builtin_administrators(const DOM_SID *sid);
183 struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
184                                             const DOM_SID *user_sid,
185                                             bool is_guest,
186                                             int num_groupsids,
187                                             const DOM_SID *groupsids);
188 void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token);
189 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
190                            int n_groups, gid_t *groups);
191
192 /* The following definitions come from groupdb/mapping.c  */
193
194 NTSTATUS add_initial_entry(gid_t gid, const char *sid, enum lsa_SidType sid_name_use, const char *nt_name, const char *comment);
195 bool get_domain_group_from_sid(DOM_SID sid, GROUP_MAP *map);
196 int smb_create_group(const char *unix_group, gid_t *new_gid);
197 int smb_delete_group(const char *unix_group);
198 int smb_set_primary_group(const char *unix_group, const char* unix_user);
199 int smb_add_user_group(const char *unix_group, const char *unix_user);
200 int smb_delete_user_group(const char *unix_group, const char *unix_user);
201 NTSTATUS pdb_default_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
202                                  DOM_SID sid);
203 NTSTATUS pdb_default_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
204                                  gid_t gid);
205 NTSTATUS pdb_default_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
206                                  const char *name);
207 NTSTATUS pdb_default_add_group_mapping_entry(struct pdb_methods *methods,
208                                                 GROUP_MAP *map);
209 NTSTATUS pdb_default_update_group_mapping_entry(struct pdb_methods *methods,
210                                                    GROUP_MAP *map);
211 NTSTATUS pdb_default_delete_group_mapping_entry(struct pdb_methods *methods,
212                                                    DOM_SID sid);
213 NTSTATUS pdb_default_enum_group_mapping(struct pdb_methods *methods,
214                                            const DOM_SID *sid, enum lsa_SidType sid_name_use,
215                                            GROUP_MAP **pp_rmap, size_t *p_num_entries,
216                                            bool unix_only);
217 NTSTATUS pdb_default_create_alias(struct pdb_methods *methods,
218                                   const char *name, uint32 *rid);
219 NTSTATUS pdb_default_delete_alias(struct pdb_methods *methods,
220                                   const DOM_SID *sid);
221 NTSTATUS pdb_default_get_aliasinfo(struct pdb_methods *methods,
222                                    const DOM_SID *sid,
223                                    struct acct_info *info);
224 NTSTATUS pdb_default_set_aliasinfo(struct pdb_methods *methods,
225                                    const DOM_SID *sid,
226                                    struct acct_info *info);
227 NTSTATUS pdb_default_add_aliasmem(struct pdb_methods *methods,
228                                   const DOM_SID *alias, const DOM_SID *member);
229 NTSTATUS pdb_default_del_aliasmem(struct pdb_methods *methods,
230                                   const DOM_SID *alias, const DOM_SID *member);
231 NTSTATUS pdb_default_enum_aliasmem(struct pdb_methods *methods,
232                                    const DOM_SID *alias, DOM_SID **pp_members,
233                                    size_t *p_num_members);
234 NTSTATUS pdb_default_alias_memberships(struct pdb_methods *methods,
235                                        TALLOC_CTX *mem_ctx,
236                                        const DOM_SID *domain_sid,
237                                        const DOM_SID *members,
238                                        size_t num_members,
239                                        uint32 **pp_alias_rids,
240                                        size_t *p_num_alias_rids);
241 NTSTATUS pdb_nop_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
242                                  DOM_SID sid);
243 NTSTATUS pdb_nop_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
244                                  gid_t gid);
245 NTSTATUS pdb_nop_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
246                                  const char *name);
247 NTSTATUS pdb_nop_add_group_mapping_entry(struct pdb_methods *methods,
248                                                 GROUP_MAP *map);
249 NTSTATUS pdb_nop_update_group_mapping_entry(struct pdb_methods *methods,
250                                                    GROUP_MAP *map);
251 NTSTATUS pdb_nop_delete_group_mapping_entry(struct pdb_methods *methods,
252                                                    DOM_SID sid);
253 NTSTATUS pdb_nop_enum_group_mapping(struct pdb_methods *methods,
254                                            enum lsa_SidType sid_name_use,
255                                            GROUP_MAP **rmap, size_t *num_entries,
256                                            bool unix_only);
257 bool pdb_get_dom_grp_info(const DOM_SID *sid, struct acct_info *info);
258 bool pdb_set_dom_grp_info(const DOM_SID *sid, const struct acct_info *info);
259 NTSTATUS pdb_create_builtin_alias(uint32 rid);
260
261 /* The following definitions come from groupdb/mapping_ldb.c  */
262
263 const struct mapping_backend *groupdb_ldb_init(void);
264
265 /* The following definitions come from groupdb/mapping_tdb.c  */
266
267 const struct mapping_backend *groupdb_tdb_init(void);
268
269 /* The following definitions come from intl/lang_tdb.c  */
270
271 bool lang_tdb_init(const char *lang);
272 const char *lang_msg(const char *msgid);
273 void lang_msg_free(const char *msgstr);
274 char *lang_tdb_current(void);
275
276 /* The following definitions come from lib/access.c  */
277
278 bool client_match(const char *tok, const void *item);
279 bool list_match(const char **list,const void *item,
280                 bool (*match_fn)(const char *, const void *));
281 bool allow_access(const char **deny_list,
282                 const char **allow_list,
283                 const char *cname,
284                 const char *caddr);
285 bool check_access(int sock, const char **allow_list, const char **deny_list);
286
287 /* The following definitions come from lib/account_pol.c  */
288
289 void account_policy_names_list(const char ***names, int *num_names);
290 const char *decode_account_policy_name(int field);
291 const char *get_account_policy_attr(int field);
292 const char *account_policy_get_desc(int field);
293 int account_policy_name_to_fieldnum(const char *name);
294 bool account_policy_get_default(int account_policy, uint32 *val);
295 bool init_account_policy(void);
296 bool account_policy_get(int field, uint32 *value);
297 bool account_policy_set(int field, uint32 value);
298 bool cache_account_policy_set(int field, uint32 value);
299 bool cache_account_policy_get(int field, uint32 *value);
300 struct db_context *get_account_pol_db( void );
301
302 /* The following definitions come from lib/adt_tree.c  */
303
304
305 /* The following definitions come from lib/afs.c  */
306
307 char *afs_createtoken_str(const char *username, const char *cell);
308 bool afs_login(connection_struct *conn);
309 bool afs_login(connection_struct *conn);
310 char *afs_createtoken_str(const char *username, const char *cell);
311
312 /* The following definitions come from lib/afs_settoken.c  */
313
314 int afs_syscall( int subcall,
315           char * path,
316           int cmd,
317           char * cmarg,
318           int follow);
319 bool afs_settoken_str(const char *token_string);
320 bool afs_settoken_str(const char *token_string);
321
322 /* The following definitions come from lib/audit.c  */
323
324 const char *audit_category_str(uint32 category);
325 const char *audit_param_str(uint32 category);
326 const char *audit_description_str(uint32 category);
327 bool get_audit_category_from_param(const char *param, uint32 *audit_category);
328 const char *audit_policy_str(TALLOC_CTX *mem_ctx, uint32 policy);
329
330 /* The following definitions come from lib/bitmap.c  */
331
332 struct bitmap *bitmap_allocate(int n);
333 void bitmap_free(struct bitmap *bm);
334 struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n);
335 int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src);
336 bool bitmap_set(struct bitmap *bm, unsigned i);
337 bool bitmap_clear(struct bitmap *bm, unsigned i);
338 bool bitmap_query(struct bitmap *bm, unsigned i);
339 int bitmap_find(struct bitmap *bm, unsigned ofs);
340
341 /* The following definitions come from lib/charcnv.c  */
342
343 NTSTATUS smb_register_charset(struct charset_functions *funcs);
344 char lp_failed_convert_char(void);
345 void lazy_initialize_conv(void);
346 void gfree_charcnv(void);
347 void init_iconv(void);
348 size_t convert_string(charset_t from, charset_t to,
349                       void const *src, size_t srclen, 
350                       void *dest, size_t destlen, bool allow_bad_conv);
351 size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen);
352 char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s);
353 char *strupper_talloc(TALLOC_CTX *ctx, const char *s);
354 size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen);
355 char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s);
356 char *strlower_talloc(TALLOC_CTX *ctx, const char *s);
357 size_t ucs2_align(const void *base_ptr, const void *p, int flags);
358 size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags);
359 size_t push_ascii_fstring(void *dest, const char *src);
360 size_t push_ascii_nstring(void *dest, const char *src);
361 size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
362 size_t pull_ascii_fstring(char *dest, const void *src);
363 size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src);
364 size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags);
365 size_t push_utf8_fstring(void *dest, const char *src);
366 bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
367                       size_t *converted_size);
368 size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
369 size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
370                         const void *base_ptr,
371                         char **ppdest,
372                         const void *src,
373                         size_t src_len,
374                         int flags);
375 size_t pull_ucs2_fstring(char *dest, const void *src);
376 bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src,
377                       size_t *converted_size);
378 bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
379                       size_t *converted_size);
380 bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src,
381                       size_t *converted_size);
382 bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
383                        size_t *converted_size);
384 size_t push_string_check_fn(const char *function, unsigned int line,
385                             void *dest, const char *src,
386                             size_t dest_len, int flags);
387 size_t push_string_base(const char *function, unsigned int line,
388                         const char *base, uint16 flags2, 
389                         void *dest, const char *src,
390                         size_t dest_len, int flags);
391 size_t pull_string_fn(const char *function,
392                         unsigned int line,
393                         const void *base_ptr,
394                         uint16 smb_flags2,
395                         char *dest,
396                         const void *src,
397                         size_t dest_len,
398                         size_t src_len,
399                         int flags);
400 size_t pull_string_talloc_fn(const char *function,
401                         unsigned int line,
402                         TALLOC_CTX *ctx,
403                         const void *base_ptr,
404                         uint16 smb_flags2,
405                         char **ppdest,
406                         const void *src,
407                         size_t src_len,
408                         int flags);
409 size_t align_string(const void *base_ptr, const char *p, int flags);
410 codepoint_t next_codepoint(const char *str, size_t *size);
411
412 /* The following definitions come from lib/clobber.c  */
413
414 void clobber_region(const char *fn, unsigned int line, char *dest, size_t len);
415
416 /* The following definitions come from lib/conn_tdb.c  */
417
418 struct db_record *connections_fetch_record(TALLOC_CTX *mem_ctx,
419                                            TDB_DATA key);
420 struct db_record *connections_fetch_entry(TALLOC_CTX *mem_ctx,
421                                           connection_struct *conn,
422                                           const char *name);
423 int connections_traverse(int (*fn)(struct db_record *rec,
424                                    void *private_data),
425                          void *private_data);
426 int connections_forall(int (*fn)(struct db_record *rec,
427                                  const struct connections_key *key,
428                                  const struct connections_data *data,
429                                  void *private_data),
430                        void *private_data);
431 bool connections_init(bool rw);
432
433 /* The following definitions come from lib/dbwrap_util.c  */
434
435 int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr);
436 int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v);
437 bool dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
438                          uint32_t *val);
439 int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v);
440 uint32_t dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
441                                      uint32_t *oldval, uint32_t change_val);
442 int32 dbwrap_change_int32_atomic(struct db_context *db, const char *keystr,
443                                  int32 *oldval, int32 change_val);
444 NTSTATUS dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf,
445                             int flag);
446 NTSTATUS dbwrap_trans_delete(struct db_context *db, TDB_DATA key);
447 NTSTATUS dbwrap_trans_store_int32(struct db_context *db, const char *keystr,
448                                   int32_t v);
449 NTSTATUS dbwrap_trans_store_uint32(struct db_context *db, const char *keystr,
450                                    uint32_t v);
451 NTSTATUS dbwrap_trans_store_bystring(struct db_context *db, const char *key,
452                                      TDB_DATA data, int flags);
453 NTSTATUS dbwrap_trans_delete_bystring(struct db_context *db, const char *key);
454
455 /* The following definitions come from lib/debug.c  */
456
457 void gfree_debugsyms(void);
458 const char *debug_classname_from_index(int ndx);
459 int debug_add_class(const char *classname);
460 int debug_lookup_classname(const char *classname);
461 bool debug_parse_levels(const char *params_str);
462 void debug_message(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data);
463 void debug_init(void);
464 void debug_register_msgs(struct messaging_context *msg_ctx);
465 void setup_logging(const char *pname, bool interactive);
466 void debug_set_logfile(const char *name);
467 bool reopen_logs( void );
468 void force_check_log_size( void );
469 bool need_to_check_log_size( void );
470 void check_log_size( void );
471 void dbgflush( void );
472 bool dbghdrclass(int level, int cls, const char *location, const char *func);
473 bool dbghdr(int level, const char *location, const char *func);
474 TALLOC_CTX *debug_ctx(void);
475
476 /* The following definitions come from lib/display_sec.c  */
477
478 char *get_sec_mask_str(TALLOC_CTX *ctx, uint32 type);
479 void display_sec_access(uint32_t *info);
480 void display_sec_ace_flags(uint8_t flags);
481 void display_sec_ace(SEC_ACE *ace);
482 void display_sec_acl(SEC_ACL *sec_acl);
483 void display_acl_type(uint16 type);
484 void display_sec_desc(SEC_DESC *sec);
485
486 /* The following definitions come from lib/dmallocmsg.c  */
487
488 void register_dmalloc_msgs(struct messaging_context *msg_ctx);
489
490 /* The following definitions come from lib/dprintf.c  */
491
492 void display_set_stderr(void);
493
494 /* The following definitions come from lib/errmap_unix.c  */
495
496 NTSTATUS map_nt_error_from_unix(int unix_error);
497 int map_errno_from_nt_status(NTSTATUS status);
498
499 /* The following definitions come from lib/fault.c  */
500 void fault_setup(void (*fn)(void *));
501 void dump_core_setup(const char *progname);
502
503 /* The following definitions come from lib/file_id.c  */
504
505 struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf);
506 bool file_id_equal(const struct file_id *id1, const struct file_id *id2);
507 const char *file_id_string_tos(const struct file_id *id);
508 void push_file_id_16(char *buf, const struct file_id *id);
509 void push_file_id_24(char *buf, const struct file_id *id);
510 void pull_file_id_24(char *buf, struct file_id *id);
511
512 /* The following definitions come from lib/gencache.c  */
513
514 bool gencache_init(void);
515 bool gencache_shutdown(void);
516 bool gencache_set(const char *keystr, const char *value, time_t timeout);
517 bool gencache_del(const char *keystr);
518 bool gencache_get(const char *keystr, char **valstr, time_t *timeout);
519 bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob, bool *expired);
520 bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t timeout);
521 void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr),
522                       void* data, const char* keystr_pattern);
523 int gencache_lock_entry( const char *key );
524 void gencache_unlock_entry( const char *key );
525
526 /* The following definitions come from lib/interface.c  */
527
528 bool ismyaddr(const struct sockaddr *ip);
529 bool ismyip_v4(struct in_addr ip);
530 bool is_local_net(const struct sockaddr *from);
531 void setup_linklocal_scope_id(struct sockaddr *pss);
532 bool is_local_net_v4(struct in_addr from);
533 int iface_count(void);
534 int iface_count_v4_nl(void);
535 const struct in_addr *first_ipv4_iface(void);
536 struct interface *get_interface(int n);
537 const struct sockaddr_storage *iface_n_sockaddr_storage(int n);
538 const struct in_addr *iface_n_ip_v4(int n);
539 const struct in_addr *iface_n_bcast_v4(int n);
540 const struct sockaddr_storage *iface_n_bcast(int n);
541 const struct sockaddr_storage *iface_ip(const struct sockaddr *ip);
542 bool iface_local(const struct sockaddr *ip);
543 void load_interfaces(void);
544 void gfree_interfaces(void);
545 bool interfaces_changed(void);
546
547 /* The following definitions come from lib/ldap_debug_handler.c  */
548
549 void init_ldap_debugging(void);
550
551 /* The following definitions come from lib/ldap_escape.c  */
552
553 char *escape_ldap_string_alloc(const char *s);
554 char *escape_rdn_val_string_alloc(const char *s);
555
556 /* The following definitions come from lib/module.c  */
557
558 NTSTATUS smb_load_module(const char *module_name);
559 int smb_load_modules(const char **modules);
560 NTSTATUS smb_probe_module(const char *subsystem, const char *module);
561 NTSTATUS smb_load_module(const char *module_name);
562 int smb_load_modules(const char **modules);
563 NTSTATUS smb_probe_module(const char *subsystem, const char *module);
564 void init_modules(void);
565
566 /* The following definitions come from lib/ms_fnmatch.c  */
567
568 int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
569                bool is_case_sensitive);
570 int gen_fnmatch(const char *pattern, const char *string);
571
572 /* The following definitions come from lib/pam_errors.c  */
573
574 NTSTATUS pam_to_nt_status(int pam_error);
575 int nt_status_to_pam(NTSTATUS nt_status);
576 NTSTATUS pam_to_nt_status(int pam_error);
577 int nt_status_to_pam(NTSTATUS nt_status);
578
579 /* The following definitions come from lib/pidfile.c  */
580
581 pid_t pidfile_pid(const char *name);
582 void pidfile_create(const char *program_name);
583
584 /* The following definitions come from lib/popt_common.c  */
585
586 void popt_common_set_auth_info(struct user_auth_info *auth_info);
587
588 /* The following definitions come from lib/privileges.c  */
589
590 bool get_privileges_for_sids(SE_PRIV *privileges, DOM_SID *slist, int scount);
591 NTSTATUS privilege_enumerate_accounts(DOM_SID **sids, int *num_sids);
592 NTSTATUS privilege_enum_sids(const SE_PRIV *mask, TALLOC_CTX *mem_ctx,
593                              DOM_SID **sids, int *num_sids);
594 bool grant_privilege(const DOM_SID *sid, const SE_PRIV *priv_mask);
595 bool grant_privilege_by_name(DOM_SID *sid, const char *name);
596 bool revoke_privilege(const DOM_SID *sid, const SE_PRIV *priv_mask);
597 bool revoke_all_privileges( DOM_SID *sid );
598 bool revoke_privilege_by_name(DOM_SID *sid, const char *name);
599 NTSTATUS privilege_create_account(const DOM_SID *sid );
600 NTSTATUS privilege_set_init(PRIVILEGE_SET *priv_set);
601 NTSTATUS privilege_set_init_by_ctx(TALLOC_CTX *mem_ctx, PRIVILEGE_SET *priv_set);
602 void privilege_set_free(PRIVILEGE_SET *priv_set);
603 NTSTATUS dup_luid_attr(TALLOC_CTX *mem_ctx, LUID_ATTR **new_la, LUID_ATTR *old_la, int count);
604 bool is_privileged_sid( const DOM_SID *sid );
605 bool grant_all_privileges( const DOM_SID *sid );
606
607 /* The following definitions come from lib/privileges_basic.c  */
608
609 bool se_priv_copy( SE_PRIV *dst, const SE_PRIV *src );
610 bool se_priv_put_all_privileges(SE_PRIV *mask);
611 void se_priv_add( SE_PRIV *mask, const SE_PRIV *addpriv );
612 void se_priv_remove( SE_PRIV *mask, const SE_PRIV *removepriv );
613 bool se_priv_equal( const SE_PRIV *mask1, const SE_PRIV *mask2 );
614 bool se_priv_from_name( const char *name, SE_PRIV *mask );
615 void dump_se_priv( int dbg_cl, int dbg_lvl, const SE_PRIV *mask );
616 bool is_privilege_assigned(const SE_PRIV *privileges,
617                            const SE_PRIV *check);
618 const char* get_privilege_dispname( const char *name );
619 bool user_has_privileges(const NT_USER_TOKEN *token, const SE_PRIV *privilege);
620 bool user_has_any_privilege(NT_USER_TOKEN *token, const SE_PRIV *privilege);
621 int count_all_privileges( void );
622 LUID_ATTR get_privilege_luid( SE_PRIV *mask );
623 const char *luid_to_privilege_name(const LUID *set);
624 bool se_priv_to_privilege_set( PRIVILEGE_SET *set, SE_PRIV *mask );
625 bool privilege_set_to_se_priv( SE_PRIV *mask, struct lsa_PrivilegeSet *privset );
626
627 /* The following definitions come from lib/readline.c  */
628
629 void smb_readline_done(void);
630 char *smb_readline(const char *prompt, void (*callback)(void),
631                    char **(completion_fn)(const char *text, int start, int end));
632 const char *smb_readline_get_line_buffer(void);
633 void smb_readline_ca_char(char c);
634 int cmd_history(void);
635
636 /* The following definitions come from lib/recvfile.c  */
637
638 ssize_t sys_recvfile(int fromfd,
639                         int tofd,
640                         SMB_OFF_T offset,
641                         size_t count);
642 ssize_t sys_recvfile(int fromfd,
643                         int tofd,
644                         SMB_OFF_T offset,
645                         size_t count);
646 ssize_t drain_socket(int sockfd, size_t count);
647
648 /* The following definitions come from lib/secdesc.c  */
649
650 uint32_t get_sec_info(const SEC_DESC *sd);
651 SEC_DESC_BUF *sec_desc_merge(TALLOC_CTX *ctx, SEC_DESC_BUF *new_sdb, SEC_DESC_BUF *old_sdb);
652 SEC_DESC *make_sec_desc(TALLOC_CTX *ctx,
653                         enum security_descriptor_revision revision,
654                         uint16 type,
655                         const DOM_SID *owner_sid, const DOM_SID *grp_sid,
656                         SEC_ACL *sacl, SEC_ACL *dacl, size_t *sd_size);
657 SEC_DESC *dup_sec_desc(TALLOC_CTX *ctx, const SEC_DESC *src);
658 NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
659                            struct security_descriptor *secdesc,
660                            uint8 **data, size_t *len);
661 NTSTATUS marshall_sec_desc_buf(TALLOC_CTX *mem_ctx,
662                                struct sec_desc_buf *secdesc_buf,
663                                uint8_t **data, size_t *len);
664 NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
665                              struct security_descriptor **psecdesc);
666 NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
667                                  struct sec_desc_buf **psecdesc_buf);
668 SEC_DESC *make_standard_sec_desc(TALLOC_CTX *ctx, const DOM_SID *owner_sid, const DOM_SID *grp_sid,
669                                  SEC_ACL *dacl, size_t *sd_size);
670 SEC_DESC_BUF *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, SEC_DESC *sec_desc);
671 SEC_DESC_BUF *dup_sec_desc_buf(TALLOC_CTX *ctx, SEC_DESC_BUF *src);
672 NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, SEC_DESC **psd, DOM_SID *sid, uint32 mask, size_t *sd_size);
673 NTSTATUS sec_desc_mod_sid(SEC_DESC *sd, DOM_SID *sid, uint32 mask);
674 NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, SEC_DESC **psd, DOM_SID *sid, size_t *sd_size);
675 NTSTATUS se_create_child_secdesc(TALLOC_CTX *ctx,
676                                         SEC_DESC **ppsd,
677                                         size_t *psize,
678                                         const SEC_DESC *parent_ctr,
679                                         const DOM_SID *owner_sid,
680                                         const DOM_SID *group_sid,
681                                         bool container);
682 NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
683                                         SEC_DESC_BUF **ppsdb,
684                                         const SEC_DESC *parent_ctr,
685                                         bool container);
686
687 /* The following definitions come from lib/select.c  */
688
689 void sys_select_signal(char c);
690 int sys_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval);
691 int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval);
692
693 /* The following definitions come from lib/sendfile.c  */
694
695 ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
696
697 /* The following definitions come from lib/server_mutex.c  */
698
699 struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
700                                      int timeout);
701
702 /* The following definitions come from lib/sharesec.c  */
703
704 SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access);
705 SEC_DESC *get_share_security( TALLOC_CTX *ctx, const char *servicename,
706                               size_t *psize);
707 bool set_share_security(const char *share_name, SEC_DESC *psd);
708 bool delete_share_security(const char *servicename);
709 bool share_access_check(const NT_USER_TOKEN *token, const char *sharename,
710                         uint32 desired_access);
711 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, SEC_DESC **ppsd);
712
713 /* The following definitions come from lib/smbldap.c  */
714
715 int smb_ldap_start_tls(LDAP *ldap_struct, int version);
716 int smb_ldap_setup_conn(LDAP **ldap_struct, const char *uri);
717 int smb_ldap_upgrade_conn(LDAP *ldap_struct, int *new_version) ;
718 int smb_ldap_setup_full_conn(LDAP **ldap_struct, const char *uri);
719 int smbldap_search(struct smbldap_state *ldap_state, 
720                    const char *base, int scope, const char *filter, 
721                    const char *attrs[], int attrsonly, 
722                    LDAPMessage **res);
723 int smbldap_search_paged(struct smbldap_state *ldap_state, 
724                          const char *base, int scope, const char *filter, 
725                          const char **attrs, int attrsonly, int pagesize,
726                          LDAPMessage **res, void **cookie);
727 int smbldap_modify(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
728 int smbldap_add(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
729 int smbldap_delete(struct smbldap_state *ldap_state, const char *dn);
730 int smbldap_extended_operation(struct smbldap_state *ldap_state, 
731                                LDAP_CONST char *reqoid, struct berval *reqdata, 
732                                LDAPControl **serverctrls, LDAPControl **clientctrls, 
733                                char **retoidp, struct berval **retdatap);
734 int smbldap_search_suffix (struct smbldap_state *ldap_state,
735                            const char *filter, const char **search_attr,
736                            LDAPMessage ** result);
737 void smbldap_free_struct(struct smbldap_state **ldap_state) ;
738 NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx,
739                       const char *location,
740                       struct smbldap_state **smbldap_state);
741 bool smbldap_has_control(LDAP *ld, const char *control);
742 bool smbldap_has_extension(LDAP *ld, const char *extension);
743 bool smbldap_has_naming_context(LDAP *ld, const char *naming_context);
744 bool smbldap_set_creds(struct smbldap_state *ldap_state, bool anon, const char *dn, const char *secret);
745
746 /* The following definitions come from lib/smbldap_util.c  */
747
748 NTSTATUS smbldap_search_domain_info(struct smbldap_state *ldap_state,
749                                     LDAPMessage ** result, const char *domain_name,
750                                     bool try_add);
751
752 /* The following definitions come from lib/smbrun.c  */
753
754 int smbrun_no_sanitize(const char *cmd, int *outfd);
755 int smbrun(const char *cmd, int *outfd);
756 int smbrunsecret(const char *cmd, const char *secret);
757
758 /* The following definitions come from lib/sock_exec.c  */
759
760 int sock_exec(const char *prog);
761
762 /* The following definitions come from lib/substitute.c  */
763
764 void free_local_machine_name(void);
765 bool set_local_machine_name(const char *local_name, bool perm);
766 const char *get_local_machine_name(void);
767 bool set_remote_machine_name(const char *remote_name, bool perm);
768 const char *get_remote_machine_name(void);
769 void sub_set_smb_name(const char *name);
770 void set_current_user_info(const char *smb_name, const char *unix_name,
771                            const char *domain);
772 const char *get_current_username(void);
773 void standard_sub_basic(const char *smb_name, const char *domain_name,
774                         char *str, size_t len);
775 char *talloc_sub_basic(TALLOC_CTX *mem_ctx, const char *smb_name,
776                        const char *domain_name, const char *str);
777 char *alloc_sub_basic(const char *smb_name, const char *domain_name,
778                       const char *str);
779 char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
780                         const char *input_string,
781                         const char *username,
782                         const char *domain,
783                         uid_t uid,
784                         gid_t gid);
785 char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
786                           const char *servicename, const char *user,
787                           const char *connectpath, gid_t gid,
788                           const char *smb_name, const char *domain_name,
789                           const char *str);
790 void standard_sub_advanced(const char *servicename, const char *user,
791                            const char *connectpath, gid_t gid,
792                            const char *smb_name, const char *domain_name,
793                            char *str, size_t len);
794 char *standard_sub_conn(TALLOC_CTX *ctx, connection_struct *conn, const char *str);
795
796 /* The following definitions come from lib/sysacls.c  */
797
798 int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p);
799 int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p);
800 int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
801 void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d);
802 int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d);
803 int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
804 int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
805 char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p);
806 SMB_ACL_T sys_acl_init(int count);
807 int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p);
808 int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type);
809 int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p);
810 int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d);
811 int sys_acl_free_text(char *text);
812 int sys_acl_free_acl(SMB_ACL_T acl_d) ;
813 int sys_acl_free_qualifier(void *qual, SMB_ACL_TAG_T tagtype);
814 int sys_acl_valid(SMB_ACL_T acl_d);
815 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, 
816                            const char *path_p, SMB_ACL_TYPE_T type);
817 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
818 int sys_acl_set_file(vfs_handle_struct *handle,
819                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
820 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
821                    SMB_ACL_T acl_d);
822 int sys_acl_delete_def_file(vfs_handle_struct *handle,
823                             const char *path);
824 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
825                            const char *path_p, SMB_ACL_TYPE_T type);
826 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
827 int sys_acl_set_file(vfs_handle_struct *handle,
828                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
829 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
830                    SMB_ACL_T acl_d);
831 int sys_acl_delete_def_file(vfs_handle_struct *handle,
832                             const char *path);
833 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
834                            const char *path_p, SMB_ACL_TYPE_T type);
835 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
836 int sys_acl_set_file(vfs_handle_struct *handle,
837                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
838 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
839                    SMB_ACL_T acl_d);
840 int sys_acl_delete_def_file(vfs_handle_struct *handle,
841                             const char *path);
842 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
843                            const char *path_p, SMB_ACL_TYPE_T type);
844 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
845 int sys_acl_set_file(vfs_handle_struct *handle,
846                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
847 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
848                    SMB_ACL_T acl_d);
849 int sys_acl_delete_def_file(vfs_handle_struct *handle,
850                             const char *path);
851 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
852                            const char *path_p, SMB_ACL_TYPE_T type);
853 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
854 int sys_acl_set_file(vfs_handle_struct *handle,
855                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
856 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
857                    SMB_ACL_T acl_d);
858 int sys_acl_delete_def_file(vfs_handle_struct *handle,
859                             const char *path);
860 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
861                            const char *path_p, SMB_ACL_TYPE_T type);
862 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
863 int sys_acl_set_file(vfs_handle_struct *handle,
864                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
865 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
866                    SMB_ACL_T acl_d);
867 int sys_acl_delete_def_file(vfs_handle_struct *handle,
868                             const char *path);
869 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
870                            const char *path_p, SMB_ACL_TYPE_T type);
871 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
872 int sys_acl_set_file(vfs_handle_struct *handle,
873                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
874 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
875                    SMB_ACL_T acl_d);
876 int sys_acl_delete_def_file(vfs_handle_struct *handle,
877                             const char *path);
878 int no_acl_syscall_error(int err);
879
880 /* The following definitions come from lib/sysquotas.c  */
881
882 int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
883 int sys_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
884
885 /* The following definitions come from lib/sysquotas_*.c  */
886
887 int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
888 int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
889
890 int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
891 int sys_set_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
892
893 /* The following definitions come from lib/system.c  */
894
895 void *sys_memalign( size_t align, size_t size );
896 int sys_usleep(long usecs);
897 ssize_t sys_read(int fd, void *buf, size_t count);
898 ssize_t sys_write(int fd, const void *buf, size_t count);
899 ssize_t sys_writev(int fd, const struct iovec *iov, int iovcnt);
900 ssize_t sys_pread(int fd, void *buf, size_t count, SMB_OFF_T off);
901 ssize_t sys_pwrite(int fd, const void *buf, size_t count, SMB_OFF_T off);
902 ssize_t sys_send(int s, const void *msg, size_t len, int flags);
903 ssize_t sys_sendto(int s,  const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
904 ssize_t sys_recv(int fd, void *buf, size_t count, int flags);
905 ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
906 int sys_fcntl_ptr(int fd, int cmd, void *arg);
907 int sys_fcntl_long(int fd, int cmd, long arg);
908 int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf);
909 int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf);
910 int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf);
911 int sys_ftruncate(int fd, SMB_OFF_T offset);
912 SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
913 int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
914 SMB_OFF_T sys_ftell(FILE *fp);
915 int sys_creat(const char *path, mode_t mode);
916 int sys_open(const char *path, int oflag, mode_t mode);
917 FILE *sys_fopen(const char *path, const char *type);
918 void kernel_flock(int fd, uint32 share_mode);
919 SMB_STRUCT_DIR *sys_opendir(const char *name);
920 SMB_STRUCT_DIRENT *sys_readdir(SMB_STRUCT_DIR *dirp);
921 void sys_seekdir(SMB_STRUCT_DIR *dirp, long offset);
922 long sys_telldir(SMB_STRUCT_DIR *dirp);
923 void sys_rewinddir(SMB_STRUCT_DIR *dirp);
924 int sys_closedir(SMB_STRUCT_DIR *dirp);
925 int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
926 int sys_waitpid(pid_t pid,int *status,int options);
927 char *sys_getwd(char *s);
928 void set_effective_capability(enum smbd_capability capability);
929 void drop_effective_capability(enum smbd_capability capability);
930 long sys_random(void);
931 void sys_srandom(unsigned int seed);
932 int groups_max(void);
933 int sys_getgroups(int setlen, gid_t *gidset);
934 int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset);
935 void sys_setpwent(void);
936 struct passwd *sys_getpwent(void);
937 void sys_endpwent(void);
938 struct passwd *sys_getpwnam(const char *name);
939 struct passwd *sys_getpwuid(uid_t uid);
940 struct group *sys_getgrnam(const char *name);
941 struct group *sys_getgrgid(gid_t gid);
942 int sys_popen(const char *command);
943 int sys_pclose(int fd);
944 ssize_t sys_getxattr (const char *path, const char *name, void *value, size_t size);
945 ssize_t sys_lgetxattr (const char *path, const char *name, void *value, size_t size);
946 ssize_t sys_fgetxattr (int filedes, const char *name, void *value, size_t size);
947 ssize_t sys_listxattr (const char *path, char *list, size_t size);
948 ssize_t sys_llistxattr (const char *path, char *list, size_t size);
949 ssize_t sys_flistxattr (int filedes, char *list, size_t size);
950 int sys_removexattr (const char *path, const char *name);
951 int sys_lremovexattr (const char *path, const char *name);
952 int sys_fremovexattr (int filedes, const char *name);
953 int sys_setxattr (const char *path, const char *name, const void *value, size_t size, int flags);
954 int sys_lsetxattr (const char *path, const char *name, const void *value, size_t size, int flags);
955 int sys_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
956 uint32 unix_dev_major(SMB_DEV_T dev);
957 uint32 unix_dev_minor(SMB_DEV_T dev);
958 int sys_aio_read(SMB_STRUCT_AIOCB *aiocb);
959 int sys_aio_write(SMB_STRUCT_AIOCB *aiocb);
960 ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb);
961 int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb);
962 int sys_aio_error(const SMB_STRUCT_AIOCB *aiocb);
963 int sys_aio_fsync(int op, SMB_STRUCT_AIOCB *aiocb);
964 int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct timespec *timeout);
965 int sys_aio_read(SMB_STRUCT_AIOCB *aiocb);
966 int sys_aio_write(SMB_STRUCT_AIOCB *aiocb);
967 ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb);
968 int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb);
969 int sys_aio_error(const SMB_STRUCT_AIOCB *aiocb);
970 int sys_aio_fsync(int op, SMB_STRUCT_AIOCB *aiocb);
971 int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct timespec *timeout);
972 int sys_getpeereid( int s, uid_t *uid);
973 int sys_getnameinfo(const struct sockaddr *psa,
974                         socklen_t salen,
975                         char *host,
976                         size_t hostlen,
977                         char *service,
978                         size_t servlen,
979                         int flags);
980 int sys_connect(int fd, const struct sockaddr * addr);
981
982 /* The following definitions come from lib/system_smbd.c  */
983
984 bool getgroups_unix_user(TALLOC_CTX *mem_ctx, const char *user,
985                          gid_t primary_gid,
986                          gid_t **ret_groups, size_t *p_ngroups);
987
988 /* The following definitions come from lib/tallocmsg.c  */
989
990 void register_msg_pool_usage(struct messaging_context *msg_ctx);
991
992 /* The following definitions come from lib/time.c  */
993
994 void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset);
995 void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
996 void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
997 time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset);
998 time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset);
999 time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset);
1000 uint32 convert_time_t_to_uint32(time_t t);
1001 time_t convert_uint32_to_time_t(uint32 u);
1002 bool nt_time_is_zero(const NTTIME *nt);
1003 time_t generalized_to_unix_time(const char *str);
1004 int get_server_zone_offset(void);
1005 int set_server_zone_offset(time_t t);
1006 char *current_timestring(TALLOC_CTX *ctx, bool hires);
1007 void srv_put_dos_date(char *buf,int offset,time_t unixdate);
1008 void srv_put_dos_date2(char *buf,int offset, time_t unixdate);
1009 void srv_put_dos_date3(char *buf,int offset,time_t unixdate);
1010 void put_long_date_timespec(char *p, struct timespec ts);
1011 void put_long_date(char *p, time_t t);
1012 struct timespec get_create_timespec(const SMB_STRUCT_STAT *st,bool fake_dirs);
1013 struct timespec get_atimespec(const SMB_STRUCT_STAT *pst);
1014 void set_atimespec(SMB_STRUCT_STAT *pst, struct timespec ts);
1015 struct timespec get_mtimespec(const SMB_STRUCT_STAT *pst);
1016 void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts);
1017 struct timespec get_ctimespec(const SMB_STRUCT_STAT *pst);
1018 void set_ctimespec(SMB_STRUCT_STAT *pst, struct timespec ts);
1019 void dos_filetime_timespec(struct timespec *tsp);
1020 time_t make_unix_date2(const void *date_ptr, int zone_offset);
1021 time_t make_unix_date3(const void *date_ptr, int zone_offset);
1022 time_t srv_make_unix_date(const void *date_ptr);
1023 time_t srv_make_unix_date2(const void *date_ptr);
1024 time_t srv_make_unix_date3(const void *date_ptr);
1025 time_t convert_timespec_to_time_t(struct timespec ts);
1026 struct timespec convert_time_t_to_timespec(time_t t);
1027 struct timespec convert_timeval_to_timespec(const struct timeval tv);
1028 struct timeval convert_timespec_to_timeval(const struct timespec ts);
1029 struct timespec timespec_current(void);
1030 struct timespec timespec_min(const struct timespec *ts1,
1031                            const struct timespec *ts2);
1032 int timespec_compare(const struct timespec *ts1, const struct timespec *ts2);
1033 struct timespec interpret_long_date(const char *p);
1034 void cli_put_dos_date(struct cli_state *cli, char *buf, int offset, time_t unixdate);
1035 void cli_put_dos_date2(struct cli_state *cli, char *buf, int offset, time_t unixdate);
1036 void cli_put_dos_date3(struct cli_state *cli, char *buf, int offset, time_t unixdate);
1037 time_t cli_make_unix_date(struct cli_state *cli, const void *date_ptr);
1038 time_t cli_make_unix_date2(struct cli_state *cli, const void *date_ptr);
1039 time_t cli_make_unix_date3(struct cli_state *cli, const void *date_ptr);
1040 bool nt_time_equals(const NTTIME *nt1, const NTTIME *nt2);
1041 void TimeInit(void);
1042 void get_process_uptime(struct timeval *ret_time);
1043 time_t nt_time_to_unix_abs(const NTTIME *nt);
1044 time_t uint64s_nt_time_to_unix_abs(const uint64_t *src);
1045 void unix_timespec_to_nt_time(NTTIME *nt, struct timespec ts);
1046 void unix_to_nt_time_abs(NTTIME *nt, time_t t);
1047 bool null_mtime(time_t mtime);
1048 const char *time_to_asc(const time_t t);
1049 const char *display_time(NTTIME nttime);
1050 bool nt_time_is_set(const NTTIME *nt);
1051
1052 /* The following definitions come from lib/username.c  */
1053
1054 char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
1055 struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
1056
1057 /* The following definitions come from lib/util.c  */
1058
1059 bool all_zero(const uint8_t *ptr, size_t size);
1060 bool set_global_myname(const char *myname);
1061 const char *global_myname(void);
1062 bool set_global_myworkgroup(const char *myworkgroup);
1063 const char *lp_workgroup(void);
1064 bool set_global_scope(const char *scope);
1065 const char *global_scope(void);
1066 void gfree_names(void);
1067 void gfree_all( void );
1068 const char *my_netbios_names(int i);
1069 bool set_netbios_aliases(const char **str_array);
1070 bool init_names(void);
1071 struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx);
1072 const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info);
1073 void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
1074                                     const char *username);
1075 void set_cmdline_auth_info_password(struct user_auth_info *auth_info,
1076                                     const char *password);
1077 const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info);
1078 bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info,
1079                                          const char *arg);
1080 int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info);
1081 void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
1082                                         bool b);
1083 bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info);
1084 void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info,
1085                                         bool b);
1086 bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info);
1087 void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info);
1088 void set_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info);
1089 void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info);
1090 bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info);
1091 bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info);
1092 bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info);
1093 struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
1094                                                  const struct user_auth_info *info);
1095 bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_info);
1096 void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info);
1097 bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid,
1098                              gid_t **gids, size_t *num_gids);
1099 bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf);
1100 bool socket_exist(const char *fname);
1101 bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st);
1102 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
1103 SMB_OFF_T get_file_size(char *file_name);
1104 char *attrib_string(uint16 mode);
1105 void show_msg(char *buf);
1106 void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num);
1107 void smb_setlen(char *buf,int len);
1108 int set_message_bcc(char *buf,int num_bytes);
1109 ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob);
1110 char *unix_clean_name(TALLOC_CTX *ctx, const char *s);
1111 char *clean_name(TALLOC_CTX *ctx, const char *s);
1112 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos);
1113 int set_blocking(int fd, bool set);
1114 void smb_msleep(unsigned int t);
1115 bool reinit_after_fork(struct messaging_context *msg_ctx,
1116                        struct event_context *ev_ctx,
1117                        bool parent_longlived);
1118 bool yesno(const char *p);
1119 void *malloc_(size_t size);
1120 void *memalign_array(size_t el_size, size_t align, unsigned int count);
1121 void *calloc_array(size_t size, size_t nmemb);
1122 void *Realloc(void *p, size_t size, bool free_old_on_error);
1123 void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
1124                         void *element, void *_array, uint32 *num_elements,
1125                         ssize_t *array_size);
1126 char *get_myname(TALLOC_CTX *ctx);
1127 char *get_mydnsdomname(TALLOC_CTX *ctx);
1128 int interpret_protocol(const char *str,int def);
1129 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
1130 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
1131 bool process_exists(const struct server_id pid);
1132 const char *uidtoname(uid_t uid);
1133 char *gidtoname(gid_t gid);
1134 uid_t nametouid(const char *name);
1135 gid_t nametogid(const char *name);
1136 void smb_panic(const char *const why);
1137 void log_stack_trace(void);
1138 const char *readdirname(SMB_STRUCT_DIR *p);
1139 bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensitive);
1140 void set_namearray(name_compare_entry **ppname_array, const char *namelist);
1141 void free_namearray(name_compare_entry *name_array);
1142 bool fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
1143 bool fcntl_getlock(int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
1144 bool is_myname(const char *s);
1145 bool is_myworkgroup(const char *s);
1146 void ra_lanman_string( const char *native_lanman );
1147 const char *get_remote_arch_str(void);
1148 void set_remote_arch(enum remote_arch_types type);
1149 enum remote_arch_types get_remote_arch(void);
1150 const char *tab_depth(int level, int depth);
1151 int str_checksum(const char *s);
1152 void zero_free(void *p, size_t size);
1153 int set_maxfiles(int requested_max);
1154 int smb_mkstemp(char *name_template);
1155 void *smb_xmalloc_array(size_t size, unsigned int count);
1156 char *myhostname(void);
1157 char *lock_path(const char *name);
1158 char *pid_path(const char *name);
1159 char *lib_path(const char *name);
1160 char *modules_path(const char *name);
1161 char *data_path(const char *name);
1162 char *state_path(const char *name);
1163 char *cache_path(const char *name);
1164 const char *shlib_ext(void);
1165 bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
1166                     const char **name);
1167 bool ms_has_wild(const char *s);
1168 bool ms_has_wild_w(const smb_ucs2_t *s);
1169 bool mask_match(const char *string, const char *pattern, bool is_case_sensitive);
1170 bool mask_match_search(const char *string, const char *pattern, bool is_case_sensitive);
1171 bool mask_match_list(const char *string, char **list, int listLen, bool is_case_sensitive);
1172 bool unix_wild_match(const char *pattern, const char *string);
1173 bool name_to_fqdn(fstring fqdn, const char *name);
1174 void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob);
1175 uint32 map_share_mode_to_deny_mode(uint32 share_access, uint32 private_options);
1176 pid_t procid_to_pid(const struct server_id *proc);
1177 void set_my_vnn(uint32 vnn);
1178 uint32 get_my_vnn(void);
1179 struct server_id pid_to_procid(pid_t pid);
1180 struct server_id procid_self(void);
1181 struct server_id server_id_self(void);
1182 bool procid_equal(const struct server_id *p1, const struct server_id *p2);
1183 bool cluster_id_equal(const struct server_id *id1,
1184                       const struct server_id *id2);
1185 bool procid_is_me(const struct server_id *pid);
1186 struct server_id interpret_pid(const char *pid_string);
1187 char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid);
1188 char *procid_str_static(const struct server_id *pid);
1189 bool procid_valid(const struct server_id *pid);
1190 bool procid_is_local(const struct server_id *pid);
1191 int this_is_smp(void);
1192 bool trans_oob(uint32_t bufsize, uint32_t offset, uint32_t length);
1193 bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
1194 char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
1195 char *get_safe_str_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
1196 int get_safe_SVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, int failval);
1197 int get_safe_IVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, int failval);
1198 void split_domain_user(TALLOC_CTX *mem_ctx,
1199                        const char *full_name,
1200                        char **domain,
1201                        char **user);
1202 void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name);
1203 void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const char *name);
1204 void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
1205 void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
1206 void *talloc_zeronull(const void *context, size_t size, const char *name);
1207 NTSTATUS split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
1208                                 char **pbase, char **pstream);
1209 bool is_valid_policy_hnd(const struct policy_handle *hnd);
1210 bool policy_hnd_equal(const struct policy_handle *hnd1,
1211                       const struct policy_handle *hnd2);
1212 const char *strip_hostname(const char *s);
1213
1214 /* The following definitions come from lib/util_file.c  */
1215
1216 char **file_lines_pload(const char *syscmd, int *numlines);
1217 void file_lines_free(char **lines);
1218
1219 /* The following definitions come from lib/util_nscd.c  */
1220
1221 void smb_nscd_flush_user_cache(void);
1222 void smb_nscd_flush_group_cache(void);
1223
1224 /* The following definitions come from lib/util_nttoken.c  */
1225
1226 NT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, const NT_USER_TOKEN *ptoken);
1227 NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
1228                         const struct nt_user_token *token_1,
1229                         const struct nt_user_token *token_2,
1230                         struct nt_user_token **token_out);
1231 bool token_sid_in_ace(const NT_USER_TOKEN *token, const SEC_ACE *ace);
1232
1233 /* The following definitions come from lib/util_pw.c  */
1234
1235 struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from) ;
1236 void flush_pwnam_cache(void);
1237 struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name);
1238 struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ;
1239
1240 /* The following definitions come from lib/util_reg.c  */
1241
1242 const char *reg_type_lookup(enum winreg_Type type);
1243 WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
1244                          uint32 *num_values, char ***values);
1245
1246 /* The following definitions come from lib/util_reg_api.c  */
1247
1248 WERROR registry_pull_value(TALLOC_CTX *mem_ctx,
1249                            struct registry_value **pvalue,
1250                            enum winreg_Type type, uint8 *data,
1251                            uint32 size, uint32 length);
1252 WERROR registry_push_value(TALLOC_CTX *mem_ctx,
1253                            const struct registry_value *value,
1254                            DATA_BLOB *presult);
1255
1256 /* The following definitions come from lib/util_seaccess.c  */
1257
1258 void se_map_generic(uint32 *access_mask, const struct generic_mapping *mapping);
1259 void security_acl_map_generic(struct security_acl *sa, const struct generic_mapping *mapping);
1260 void se_map_standard(uint32 *access_mask, struct standard_mapping *mapping);
1261 NTSTATUS se_access_check(const SEC_DESC *sd, const NT_USER_TOKEN *token,
1262                      uint32 acc_desired, uint32 *acc_granted);
1263 NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size);
1264
1265 /* The following definitions come from lib/util_sec.c  */
1266
1267 void sec_init(void);
1268 uid_t sec_initial_uid(void);
1269 gid_t sec_initial_gid(void);
1270 bool non_root_mode(void);
1271 void gain_root_privilege(void);
1272 void gain_root_group_privilege(void);
1273 void set_effective_uid(uid_t uid);
1274 void set_effective_gid(gid_t gid);
1275 void save_re_uid(void);
1276 void restore_re_uid_fromroot(void);
1277 void restore_re_uid(void);
1278 void save_re_gid(void);
1279 void restore_re_gid(void);
1280 int set_re_uid(void);
1281 void become_user_permanently(uid_t uid, gid_t gid);
1282 bool is_setuid_root(void) ;
1283
1284 /* The following definitions come from lib/util_sid.c  */
1285
1286 const char *sid_type_lookup(uint32 sid_type) ;
1287 NT_USER_TOKEN *get_system_token(void) ;
1288 const char *get_global_sam_name(void) ;
1289 char *sid_to_fstring(fstring sidstr_out, const DOM_SID *sid);
1290 char *sid_string_talloc(TALLOC_CTX *mem_ctx, const DOM_SID *sid);
1291 char *sid_string_dbg(const DOM_SID *sid);
1292 char *sid_string_tos(const DOM_SID *sid);
1293 bool string_to_sid(DOM_SID *sidout, const char *sidstr);
1294 DOM_SID *string_sid_talloc(TALLOC_CTX *mem_ctx, const char *sidstr);
1295 bool sid_append_rid(DOM_SID *sid, uint32 rid);
1296 bool sid_compose(DOM_SID *dst, const DOM_SID *domain_sid, uint32 rid);
1297 bool sid_split_rid(DOM_SID *sid, uint32 *rid);
1298 bool sid_peek_rid(const DOM_SID *sid, uint32 *rid);
1299 bool sid_peek_check_rid(const DOM_SID *exp_dom_sid, const DOM_SID *sid, uint32 *rid);
1300 void sid_copy(DOM_SID *dst, const DOM_SID *src);
1301 bool sid_linearize(char *outbuf, size_t len, const DOM_SID *sid);
1302 bool sid_parse(const char *inbuf, size_t len, DOM_SID *sid);
1303 int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2);
1304 int sid_compare_domain(const DOM_SID *sid1, const DOM_SID *sid2);
1305 bool sid_equal(const DOM_SID *sid1, const DOM_SID *sid2);
1306 bool non_mappable_sid(DOM_SID *sid);
1307 char *sid_binstring(const DOM_SID *sid);
1308 char *sid_binstring_hex(const DOM_SID *sid);
1309 DOM_SID *sid_dup_talloc(TALLOC_CTX *ctx, const DOM_SID *src);
1310 NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
1311                           DOM_SID **sids, size_t *num);
1312 NTSTATUS add_sid_to_array_unique(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
1313                                  DOM_SID **sids, size_t *num_sids);
1314 void del_sid_from_array(const DOM_SID *sid, DOM_SID **sids, size_t *num);
1315 bool add_rid_to_array_unique(TALLOC_CTX *mem_ctx,
1316                                     uint32 rid, uint32 **pp_rids, size_t *p_num);
1317 bool is_null_sid(const DOM_SID *sid);
1318 bool is_sid_in_token(const NT_USER_TOKEN *token, const DOM_SID *sid);
1319 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
1320                               const struct netr_SamInfo3 *info3,
1321                               DOM_SID **user_sids,
1322                               size_t *num_user_sids,
1323                               bool include_user_group_rid,
1324                               bool skip_ressource_groups);
1325
1326 /* The following definitions come from lib/util_sock.c  */
1327
1328 bool interpret_string_addr_internal(struct addrinfo **ppres,
1329                                         const char *str, int flags);
1330 bool is_broadcast_addr(const struct sockaddr *pss);
1331 bool interpret_string_addr(struct sockaddr_storage *pss,
1332                 const char *str,
1333                 int flags);
1334 bool is_loopback_ip_v4(struct in_addr ip);
1335 bool is_loopback_addr(const struct sockaddr *pss);
1336 bool is_zero_addr(const struct sockaddr *pss);
1337 void zero_ip_v4(struct in_addr *ip);
1338 void zero_sockaddr(struct sockaddr_storage *pss);
1339 void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
1340                 struct in_addr ip);
1341 bool same_net(const struct sockaddr *ip1,
1342                 const struct sockaddr *ip2,
1343                 const struct sockaddr *mask);
1344 bool sockaddr_equal(const struct sockaddr *ip1,
1345                 const struct sockaddr *ip2);
1346 bool is_address_any(const struct sockaddr *psa);
1347 uint16_t get_sockaddr_port(const struct sockaddr_storage *pss);
1348 char *print_sockaddr(char *dest,
1349                         size_t destlen,
1350                         const struct sockaddr_storage *psa);
1351 char *print_canonical_sockaddr(TALLOC_CTX *ctx,
1352                         const struct sockaddr_storage *pss);
1353 void set_sockaddr_port(struct sockaddr *psa, uint16_t port);
1354 const char *client_name(int fd);
1355 int get_socket_port(int fd);
1356 const char *client_addr(int fd, char *addr, size_t addrlen);
1357 const char *client_socket_addr(int fd, char *addr, size_t addr_len);
1358 int client_socket_port(int fd);
1359 void set_smb_read_error(enum smb_read_errors *pre,
1360                         enum smb_read_errors newerr);
1361 void cond_set_smb_read_error(enum smb_read_errors *pre,
1362                         enum smb_read_errors newerr);
1363 bool is_a_socket(int fd);
1364 void set_socket_options(int fd, const char *options);
1365 ssize_t read_udp_v4_socket(int fd,
1366                         char *buf,
1367                         size_t len,
1368                         struct sockaddr_storage *psa);
1369 NTSTATUS read_socket_with_timeout(int fd, char *buf,
1370                                   size_t mincnt, size_t maxcnt,
1371                                   unsigned int time_out,
1372                                   size_t *size_ret);
1373 NTSTATUS read_data(int fd, char *buffer, size_t N);
1374 ssize_t write_data(int fd, const char *buffer, size_t N);
1375 ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt);
1376 bool send_keepalive(int client);
1377 NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
1378                                           unsigned int timeout,
1379                                           size_t *len);
1380 NTSTATUS read_smb_length(int fd, char *inbuf, unsigned int timeout,
1381                          size_t *len);
1382 NTSTATUS receive_smb_raw(int fd,
1383                         char *buffer,
1384                         size_t buflen,
1385                         unsigned int timeout,
1386                         size_t maxlen,
1387                         size_t *p_len);
1388 int open_socket_in(int type,
1389                 uint16_t port,
1390                 int dlevel,
1391                 const struct sockaddr_storage *psock,
1392                 bool rebind);
1393 NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
1394                          int timeout, int *pfd);
1395 struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
1396                                         struct event_context *ev,
1397                                         const struct sockaddr_storage *pss,
1398                                         uint16_t port,
1399                                         int timeout);
1400 NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
1401 struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
1402                                               struct event_context *ev,
1403                                               struct timeval wait_time,
1404                                               const struct sockaddr_storage *pss,
1405                                               uint16_t port,
1406                                               int timeout);
1407 NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd);
1408 bool open_any_socket_out(struct sockaddr_storage *addrs, int num_addrs,
1409                          int timeout, int *fd_index, int *fd);
1410 int open_udp_socket(const char *host, int port);
1411 const char *get_peer_name(int fd, bool force_lookup);
1412 const char *get_peer_addr(int fd, char *addr, size_t addr_len);
1413 int create_pipe_sock(const char *socket_dir,
1414                      const char *socket_name,
1415                      mode_t dir_perms);
1416 const char *get_mydnsfullname(void);
1417 bool is_myname_or_ipaddr(const char *s);
1418 struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx,
1419                                  struct tevent_context *ev,
1420                                  int fd);
1421 ssize_t read_smb_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1422                       uint8_t **pbuf, int *perrno);
1423 struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
1424                                     struct tevent_context *ev,
1425                                     struct fncall_context *ctx,
1426                                     const char *node,
1427                                     const char *service,
1428                                     const struct addrinfo *hints);
1429 int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
1430
1431 /* The following definitions come from lib/util_str.c  */
1432
1433 bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
1434 bool next_token_talloc(TALLOC_CTX *ctx,
1435                         const char **ptr,
1436                         char **pp_buff,
1437                         const char *sep);
1438 bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
1439                         const char **ptr,
1440                         char **pp_buff,
1441                         const char *sep);
1442 int StrCaseCmp(const char *s, const char *t);
1443 int StrnCaseCmp(const char *s, const char *t, size_t len);
1444 bool strnequal(const char *s1,const char *s2,size_t n);
1445 bool strcsequal(const char *s1,const char *s2);
1446 void strnorm(char *s, int case_default);
1447 bool strisnormal(const char *s, int case_default);
1448 char *push_skip_string(char *buf);
1449 char *skip_string(const char *base, size_t len, char *buf);
1450 size_t str_charnum(const char *s);
1451 size_t str_ascii_charnum(const char *s);
1452 bool trim_char(char *s,char cfront,char cback);
1453 bool strhasupper(const char *s);
1454 bool strhaslower(const char *s);
1455 char *safe_strcpy_fn(const char *fn,
1456                 int line,
1457                 char *dest,
1458                 const char *src,
1459                 size_t maxlength);
1460 char *safe_strcat_fn(const char *fn,
1461                 int line,
1462                 char *dest,
1463                 const char *src,
1464                 size_t maxlength);
1465 char *alpha_strcpy_fn(const char *fn,
1466                 int line,
1467                 char *dest,
1468                 const char *src,
1469                 const char *other_safe_chars,
1470                 size_t maxlength);
1471 char *StrnCpy_fn(const char *fn, int line,char *dest,const char *src,size_t n);
1472 bool in_list(const char *s, const char *list, bool casesensitive);
1473 void string_free(char **s);
1474 bool string_set(char **dest,const char *src);
1475 void string_sub2(char *s,const char *pattern, const char *insert, size_t len,
1476                  bool remove_unsafe_characters, bool replace_once,
1477                  bool allow_trailing_dollar);
1478 void string_sub_once(char *s, const char *pattern,
1479                 const char *insert, size_t len);
1480 void string_sub(char *s,const char *pattern, const char *insert, size_t len);
1481 void fstring_sub(char *s,const char *pattern,const char *insert);
1482 char *realloc_string_sub2(char *string,
1483                         const char *pattern,
1484                         const char *insert,
1485                         bool remove_unsafe_characters,
1486                         bool allow_trailing_dollar);
1487 char *realloc_string_sub(char *string,
1488                         const char *pattern,
1489                         const char *insert);
1490 char *talloc_string_sub2(TALLOC_CTX *mem_ctx, const char *src,
1491                         const char *pattern,
1492                         const char *insert,
1493                         bool remove_unsafe_characters,
1494                         bool replace_once,
1495                         bool allow_trailing_dollar);
1496 char *talloc_string_sub(TALLOC_CTX *mem_ctx,
1497                         const char *src,
1498                         const char *pattern,
1499                         const char *insert);
1500 void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
1501 char *talloc_all_string_sub(TALLOC_CTX *ctx,
1502                                 const char *src,
1503                                 const char *pattern,
1504                                 const char *insert);
1505 char *octal_string(int i);
1506 char *string_truncate(char *s, unsigned int length);
1507 char *strchr_m(const char *src, char c);
1508 char *strrchr_m(const char *s, char c);
1509 char *strnrchr_m(const char *s, char c, unsigned int n);
1510 char *strstr_m(const char *src, const char *findstr);
1511 void strlower_m(char *s);
1512 void strupper_m(char *s);
1513 size_t strlen_m(const char *s);
1514 size_t strlen_m_term(const char *s);
1515 size_t strlen_m_term_null(const char *s);
1516 char *binary_string_rfc2254(char *buf, int len);
1517 char *binary_string(char *buf, int len);
1518 int fstr_sprintf(fstring s, const char *fmt, ...);
1519 bool str_list_sub_basic( char **list, const char *smb_name,
1520                          const char *domain_name );
1521 bool str_list_substitute(char **list, const char *pattern, const char *insert);
1522 bool str_list_check(const char **list, const char *s);
1523 bool str_list_check_ci(const char **list, const char *s);
1524
1525 char *ipstr_list_make(char **ipstr_list,
1526                         const struct ip_service *ip_list,
1527                         int ip_count);
1528 int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list);
1529 void ipstr_list_free(char* ipstr_list);
1530 void rfc1738_unescape(char *buf);
1531 DATA_BLOB base64_decode_data_blob(const char *s);
1532 void base64_decode_inplace(char *s);
1533 char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data);
1534 uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr);
1535 SMB_OFF_T conv_str_size(const char * str);
1536 void string_append(char **left, const char *right);
1537 bool add_string_to_array(TALLOC_CTX *mem_ctx,
1538                          const char *str, const char ***strings,
1539                          int *num);
1540 void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
1541                     size_t *bufsize, const char *fmt, ...);
1542 int asprintf_strupper_m(char **strp, const char *fmt, ...);
1543 char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...);
1544 char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...);
1545 char *sstring_sub(const char *src, char front, char back);
1546 bool validate_net_name( const char *name,
1547                 const char *invalid_chars,
1548                 int max_len);
1549 char *escape_shell_string(const char *src);
1550 char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
1551
1552 /* The following definitions come from lib/util_unistr.c  */
1553
1554 void gfree_case_tables(void);
1555 void load_case_tables(void);
1556 void init_valid_table(void);
1557 size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate);
1558 char *skip_unibuf(char *src, size_t len);
1559 int rpcstr_pull(char* dest, void *src, int dest_len, int src_len, int flags);
1560 int rpcstr_pull_talloc(TALLOC_CTX *ctx,
1561                         char **dest,
1562                         void *src,
1563                         int src_len,
1564                         int flags);
1565 int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags);
1566 int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src);
1567 smb_ucs2_t toupper_w(smb_ucs2_t val);
1568 smb_ucs2_t tolower_w( smb_ucs2_t val );
1569 bool islower_w(smb_ucs2_t c);
1570 bool isupper_w(smb_ucs2_t c);
1571 bool isvalid83_w(smb_ucs2_t c);
1572 size_t strlen_w(const smb_ucs2_t *src);
1573 size_t strnlen_w(const smb_ucs2_t *src, size_t max);
1574 smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
1575 smb_ucs2_t *strchr_wa(const smb_ucs2_t *s, char c);
1576 smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
1577 smb_ucs2_t *strnrchr_w(const smb_ucs2_t *s, smb_ucs2_t c, unsigned int n);
1578 smb_ucs2_t *strstr_w(const smb_ucs2_t *s, const smb_ucs2_t *ins);
1579 bool strlower_w(smb_ucs2_t *s);
1580 bool strupper_w(smb_ucs2_t *s);
1581 void strnorm_w(smb_ucs2_t *s, int case_default);
1582 int strcmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b);
1583 int strncmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b, size_t len);
1584 int strcasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b);
1585 int strncasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b, size_t len);
1586 bool strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
1587 bool strnequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2,size_t n);
1588 smb_ucs2_t *strdup_w(const smb_ucs2_t *src);
1589 smb_ucs2_t *strndup_w(const smb_ucs2_t *src, size_t len);
1590 smb_ucs2_t *strncpy_w(smb_ucs2_t *dest, const smb_ucs2_t *src, const size_t max);
1591 smb_ucs2_t *strncat_w(smb_ucs2_t *dest, const smb_ucs2_t *src, const size_t max);
1592 smb_ucs2_t *strcat_w(smb_ucs2_t *dest, const smb_ucs2_t *src);
1593 void string_replace_w(smb_ucs2_t *s, smb_ucs2_t oldc, smb_ucs2_t newc);
1594 bool trim_string_w(smb_ucs2_t *s, const smb_ucs2_t *front,
1595                                   const smb_ucs2_t *back);
1596 int strcmp_wa(const smb_ucs2_t *a, const char *b);
1597 int strncmp_wa(const smb_ucs2_t *a, const char *b, size_t len);
1598 smb_ucs2_t *strpbrk_wa(const smb_ucs2_t *s, const char *p);
1599 smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins);
1600 int toupper_ascii(int c);
1601 int tolower_ascii(int c);
1602 int isupper_ascii(int c);
1603 int islower_ascii(int c);
1604
1605 /* The following definitions come from lib/util_uuid.c  */
1606
1607 void smb_uuid_pack(const struct GUID uu, UUID_FLAT *ptr);
1608 void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu);
1609 char *guid_binstring(const struct GUID *guid);
1610
1611 /* The following definitions come from lib/version.c  */
1612
1613 const char *samba_version_string(void);
1614
1615 /* The following definitions come from lib/winbind_util.c  */
1616
1617 bool winbind_lookup_name(const char *dom_name, const char *name, DOM_SID *sid, 
1618                          enum lsa_SidType *name_type);
1619 bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, 
1620                         const char **domain, const char **name,
1621                         enum lsa_SidType *name_type);
1622 bool winbind_ping(void);
1623 bool winbind_sid_to_uid(uid_t *puid, const DOM_SID *sid);
1624 bool winbind_uid_to_sid(DOM_SID *sid, uid_t uid);
1625 bool winbind_sid_to_gid(gid_t *pgid, const DOM_SID *sid);
1626 bool winbind_gid_to_sid(DOM_SID *sid, gid_t gid);
1627 struct passwd * winbind_getpwnam(const char * sname);
1628 struct passwd * winbind_getpwsid(const DOM_SID *sid);
1629 wbcErr wb_is_trusted_domain(const char *domain);
1630 bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
1631                          const DOM_SID *domain_sid,
1632                          int num_rids, uint32 *rids,
1633                          const char **domain_name,
1634                          const char ***names, enum lsa_SidType **types);
1635 bool winbind_allocate_uid(uid_t *uid);
1636 bool winbind_allocate_gid(gid_t *gid);
1637 bool winbind_get_groups(TALLOC_CTX *mem_ctx,
1638                         const char *account,
1639                         uint32_t *num_groups,
1640                         gid_t ** _groups);
1641 bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
1642                              const DOM_SID *dom_sid,
1643                              const DOM_SID *members,
1644                              size_t num_members,
1645                              uint32_t **pp_alias_rids,
1646                              size_t *p_num_alias_rids);
1647
1648
1649 /* The following definitions come from lib/wins_srv.c  */
1650
1651 bool wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip);
1652 void wins_srv_alive(struct in_addr wins_ip, struct in_addr src_ip);
1653 void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip);
1654 unsigned wins_srv_count(void);
1655 char **wins_srv_tags(void);
1656 void wins_srv_tags_free(char **list);
1657 struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip);
1658 unsigned wins_srv_count_tag(const char *tag);
1659
1660 /* The following definitions come from libads/ads_status.c  */
1661
1662 ADS_STATUS ads_build_error(enum ads_error_type etype, 
1663                            int rc, int minor_status);
1664 ADS_STATUS ads_build_nt_error(enum ads_error_type etype, 
1665                            NTSTATUS nt_status);
1666 NTSTATUS ads_ntstatus(ADS_STATUS status);
1667 const char *ads_errstr(ADS_STATUS status);
1668 NTSTATUS gss_err_to_ntstatus(uint32 maj, uint32 min);
1669
1670 /* The following definitions come from libads/ads_struct.c  */
1671
1672 char *ads_build_path(const char *realm, const char *sep, const char *field, int reverse);
1673 char *ads_build_dn(const char *realm);
1674 char *ads_build_domain(const char *dn);
1675 ADS_STRUCT *ads_init(const char *realm, 
1676                      const char *workgroup,
1677                      const char *ldap_server);
1678 void ads_destroy(ADS_STRUCT **ads);
1679
1680 /* The following definitions come from libads/ads_utils.c  */
1681
1682 uint32 ads_acb2uf(uint32 acb);
1683 uint32 ads_uf2acb(uint32 uf);
1684 uint32 ads_uf2atype(uint32 uf);
1685 uint32 ads_gtype2atype(uint32 gtype);
1686 enum lsa_SidType ads_atype_map(uint32 atype);
1687 const char *ads_get_ldap_server_name(ADS_STRUCT *ads);
1688
1689 /* The following definitions come from libads/authdata.c  */
1690
1691 struct PAC_LOGON_INFO *get_logon_info_from_pac(struct PAC_DATA *pac_data);
1692 NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx,
1693                              const char *name,
1694                              const char *pass,
1695                              time_t time_offset,
1696                              time_t *expire_time,
1697                              time_t *renew_till_time,
1698                              const char *cache_name,
1699                              bool request_pac,
1700                              bool add_netbios_addr,
1701                              time_t renewable_time,
1702                              struct PAC_DATA **pac_ret);
1703 NTSTATUS kerberos_return_info3_from_pac(TALLOC_CTX *mem_ctx,
1704                                         const char *name,
1705                                         const char *pass,
1706                                         time_t time_offset,
1707                                         time_t *expire_time,
1708                                         time_t *renew_till_time,
1709                                         const char *cache_name,
1710                                         bool request_pac,
1711                                         bool add_netbios_addr,
1712                                         time_t renewable_time,
1713                                         struct netr_SamInfo3 **info3);
1714
1715 /* The following definitions come from libads/cldap.c  */
1716 bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
1717                         const char *server,
1718                         const char *realm,
1719                         uint32_t nt_version,
1720                         struct netlogon_samlogon_response **reply);
1721 bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
1722                           const char *server,
1723                           const char *realm,
1724                           struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5);
1725
1726 /* The following definitions come from libads/disp_sec.c  */
1727
1728 void ads_disp_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, SEC_DESC *sd);
1729
1730 /* The following definitions come from libads/dns.c  */
1731
1732 NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
1733                                 const char *dnsdomain,
1734                                 struct dns_rr_ns **nslist,
1735                                 int *numns);
1736 bool sitename_store(const char *realm, const char *sitename);
1737 char *sitename_fetch(const char *realm);
1738 bool stored_sitename_changed(const char *realm, const char *sitename);
1739 NTSTATUS ads_dns_query_dcs(TALLOC_CTX *ctx,
1740                            const char *realm,
1741                            const char *sitename,
1742                            struct dns_rr_srv **dclist,
1743                            int *numdcs );
1744 NTSTATUS ads_dns_query_gcs(TALLOC_CTX *ctx,
1745                            const char *realm,
1746                            const char *sitename,
1747                            struct dns_rr_srv **dclist,
1748                            int *numdcs );
1749 NTSTATUS ads_dns_query_kdcs(TALLOC_CTX *ctx,
1750                             const char *dns_forest_name,
1751                             const char *sitename,
1752                             struct dns_rr_srv **dclist,
1753                             int *numdcs );
1754 NTSTATUS ads_dns_query_pdc(TALLOC_CTX *ctx,
1755                            const char *dns_domain_name,
1756                            struct dns_rr_srv **dclist,
1757                            int *numdcs );
1758 NTSTATUS ads_dns_query_dcs_guid(TALLOC_CTX *ctx,
1759                                 const char *dns_forest_name,
1760                                 const struct GUID *domain_guid,
1761                                 struct dns_rr_srv **dclist,
1762                                 int *numdcs );
1763
1764 /* The following definitions come from libads/kerberos.c  */
1765
1766 int kerberos_kinit_password_ext(const char *principal,
1767                                 const char *password,
1768                                 int time_offset,
1769                                 time_t *expire_time,
1770                                 time_t *renew_till_time,
1771                                 const char *cache_name,
1772                                 bool request_pac,
1773                                 bool add_netbios_addr,
1774                                 time_t renewable_time,
1775                                 NTSTATUS *ntstatus);
1776 int ads_kinit_password(ADS_STRUCT *ads);
1777 int ads_kdestroy(const char *cc_name);
1778 char* kerberos_standard_des_salt( void );
1779 bool kerberos_secrets_store_des_salt( const char* salt );
1780 char* kerberos_secrets_fetch_des_salt( void );
1781 char *kerberos_get_default_realm_from_ccache( void );
1782 bool kerberos_secrets_store_salting_principal(const char *service,
1783                                               int enctype,
1784                                               const char *principal);
1785 int kerberos_kinit_password(const char *principal,
1786                             const char *password,
1787                             int time_offset,
1788                             const char *cache_name);
1789 bool create_local_private_krb5_conf_for_domain(const char *realm,
1790                                                 const char *domain,
1791                                                 const char *sitename,
1792                                                 struct sockaddr_storage *pss);
1793
1794
1795 /* The following definitions come from libsmb/credentials.c  */
1796
1797 char *credstr(const unsigned char *cred);
1798 void creds_server_init(uint32 neg_flags,
1799                         struct dcinfo *dc,
1800                         struct netr_Credential *clnt_chal,
1801                         struct netr_Credential *srv_chal,
1802                         const unsigned char mach_pw[16],
1803                         struct netr_Credential *init_chal_out);
1804 bool netlogon_creds_server_check(const struct dcinfo *dc,
1805                                  const struct netr_Credential *rcv_cli_chal_in);
1806 bool netlogon_creds_server_step(struct dcinfo *dc,
1807                                 const struct netr_Authenticator *received_cred,
1808                                 struct netr_Authenticator *cred_out);
1809 void cred_hash3(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw);
1810
1811 /* The following definitions come from libads/kerberos_keytab.c  */
1812
1813 int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc);
1814 int ads_keytab_flush(ADS_STRUCT *ads);
1815 int ads_keytab_create_default(ADS_STRUCT *ads);
1816 int ads_keytab_list(const char *keytab_name);
1817
1818 /* The following definitions come from libads/kerberos_verify.c  */
1819
1820 NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx,
1821                            const char *realm,
1822                            time_t time_offset,
1823                            const DATA_BLOB *ticket,
1824                            char **principal,
1825                            struct PAC_DATA **pac_data,
1826                            DATA_BLOB *ap_rep,
1827                            DATA_BLOB *session_key,
1828                            bool use_replay_cache);
1829
1830 /* The following definitions come from libads/krb5_errs.c  */
1831
1832
1833 /* The following definitions come from libads/krb5_setpw.c  */
1834
1835 ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *princ, 
1836                                  const char *newpw, int time_offset);
1837 ADS_STATUS kerberos_set_password(const char *kpasswd_server, 
1838                                  const char *auth_principal, const char *auth_password,
1839                                  const char *target_principal, const char *new_password,
1840                                  int time_offset);
1841 ADS_STATUS ads_set_machine_password(ADS_STRUCT *ads,
1842                                     const char *machine_account,
1843                                     const char *password);
1844
1845 /* The following definitions come from libads/ldap.c  */
1846
1847 bool ads_sitename_match(ADS_STRUCT *ads);
1848 bool ads_closest_dc(ADS_STRUCT *ads);
1849 ADS_STATUS ads_connect(ADS_STRUCT *ads);
1850 ADS_STATUS ads_connect_user_creds(ADS_STRUCT *ads);
1851 ADS_STATUS ads_connect_gc(ADS_STRUCT *ads);
1852 void ads_disconnect(ADS_STRUCT *ads);
1853 ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
1854                                 int scope, const char *expr, const char **attrs,
1855                                 bool (*fn)(ADS_STRUCT *, char *, void **, void *), 
1856                                 void *data_area);
1857 char *ads_parent_dn(const char *dn);
1858 ADS_MODLIST ads_init_mods(TALLOC_CTX *ctx);
1859 ADS_STATUS ads_mod_str(TALLOC_CTX *ctx, ADS_MODLIST *mods, 
1860                        const char *name, const char *val);
1861 ADS_STATUS ads_mod_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
1862                            const char *name, const char **vals);
1863 ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods);
1864 ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ADS_MODLIST mods);
1865 ADS_STATUS ads_del_dn(ADS_STRUCT *ads, char *del_dn);
1866 char *ads_ou_string(ADS_STRUCT *ads, const char *org_unit);
1867 char *ads_default_ou_string(ADS_STRUCT *ads, const char *wknguid);
1868 ADS_STATUS ads_add_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
1869                                 const char *name, const char **vals);
1870 uint32 ads_get_kvno(ADS_STRUCT *ads, const char *account_name);
1871 uint32_t ads_get_machine_kvno(ADS_STRUCT *ads, const char *machine_name);
1872 ADS_STATUS ads_clear_service_principal_names(ADS_STRUCT *ads, const char *machine_name);
1873 ADS_STATUS ads_add_service_principal_name(ADS_STRUCT *ads, const char *machine_name, 
1874                                           const char *my_fqdn, const char *spn);
1875 ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads, const char *machine_name, 
1876                                    const char *org_unit);
1877 ADS_STATUS ads_move_machine_acct(ADS_STRUCT *ads, const char *machine_name, 
1878                                  const char *org_unit, bool *moved);
1879 int ads_count_replies(ADS_STRUCT *ads, void *res);
1880 ADS_STATUS ads_USN(ADS_STRUCT *ads, uint32 *usn);
1881 ADS_STATUS ads_current_time(ADS_STRUCT *ads);
1882 ADS_STATUS ads_domain_func_level(ADS_STRUCT *ads, uint32 *val);
1883 ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, DOM_SID *sid);
1884 ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_name);
1885 ADS_STATUS ads_site_dn_for_machine(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char *computer_name, const char **site_dn);
1886 ADS_STATUS ads_upn_suffixes(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char ***suffixes, size_t *num_suffixes);
1887 ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
1888                                 TALLOC_CTX *mem_ctx,
1889                                 char ***ous,
1890                                 size_t *num_ous);
1891 ADS_STATUS ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx,
1892                                         const char *extended_dn,
1893                                         enum ads_extended_dn_flags flags,
1894                                         DOM_SID *sid);
1895 char* ads_get_dnshostname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
1896 char* ads_get_upn( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
1897 char* ads_get_samaccountname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
1898 ADS_STATUS ads_join_realm(ADS_STRUCT *ads, const char *machine_name,
1899                         uint32 account_type, const char *org_unit);
1900 ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname);
1901 ADS_STATUS ads_find_samaccount(ADS_STRUCT *ads,
1902                                TALLOC_CTX *mem_ctx,
1903                                const char *samaccountname,
1904                                uint32 *uac_ret,
1905                                const char **dn_ret);
1906 ADS_STATUS ads_config_path(ADS_STRUCT *ads, 
1907                            TALLOC_CTX *mem_ctx, 
1908                            char **config_path);
1909 const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads, 
1910                                                 const char *config_path, 
1911                                                 TALLOC_CTX *mem_ctx, 
1912                                                 const struct GUID *rights_guid);
1913 ADS_STATUS ads_check_ou_dn(TALLOC_CTX *mem_ctx,
1914                            ADS_STRUCT *ads,
1915                            const char **account_ou);
1916
1917 /* The following definitions come from libads/ldap_printer.c  */
1918
1919 ADS_STATUS ads_mod_printer_entry(ADS_STRUCT *ads, char *prt_dn,
1920                                  TALLOC_CTX *ctx, const ADS_MODLIST *mods);
1921 ADS_STATUS ads_add_printer_entry(ADS_STRUCT *ads, char *prt_dn,
1922                                         TALLOC_CTX *ctx, ADS_MODLIST *mods);
1923 WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli, 
1924                                           TALLOC_CTX *mem_ctx,
1925                                           ADS_MODLIST *mods,
1926                                           const char *printer);
1927 bool get_local_printer_publishing_data(TALLOC_CTX *mem_ctx,
1928                                        ADS_MODLIST *mods,
1929                                        NT_PRINTER_DATA *data);
1930
1931 /* The following definitions come from libads/ldap_schema.c  */
1932
1933 ADS_STATUS ads_get_attrnames_by_oids(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx,
1934                                      const char *schema_path,
1935                                      const char **OIDs, size_t num_OIDs, 
1936                                      char ***OIDs_out, char ***names, size_t *count);
1937 const char *ads_get_attrname_by_guid(ADS_STRUCT *ads, 
1938                                      const char *schema_path, 
1939                                      TALLOC_CTX *mem_ctx, 
1940                                      const struct GUID *schema_guid);
1941 const char *ads_get_attrname_by_oid(ADS_STRUCT *ads, const char *schema_path, TALLOC_CTX *mem_ctx, const char * OID);
1942 ADS_STATUS ads_schema_path(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char **schema_path);
1943 ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx,
1944                                           ADS_STRUCT *ads,
1945                                           enum wb_posix_mapping map_type,
1946                                           struct posix_schema **s ) ;
1947
1948 /* The following definitions come from libads/ldap_user.c  */
1949
1950 ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user, 
1951                              const char *container, const char *fullname);
1952 ADS_STATUS ads_add_group_acct(ADS_STRUCT *ads, const char *group, 
1953                               const char *container, const char *comment);
1954
1955 /* The following definitions come from libads/ldap_utils.c  */
1956
1957 ADS_STATUS ads_ranged_search(ADS_STRUCT *ads, 
1958                              TALLOC_CTX *mem_ctx,
1959                              int scope,
1960                              const char *base,
1961                              const char *filter,
1962                              void *args,
1963                              const char *range_attr,
1964                              char ***strings,
1965                              size_t *num_strings);
1966 ADS_STATUS ads_ranged_search_internal(ADS_STRUCT *ads, 
1967                                       TALLOC_CTX *mem_ctx,
1968                                       int scope,
1969                                       const char *base,
1970                                       const char *filter,
1971                                       const char **attrs,
1972                                       void *args,
1973                                       const char *range_attr,
1974                                       char ***strings,
1975                                       size_t *num_strings,
1976                                       uint32 *first_usn,
1977                                       int *num_retries,
1978                                       bool *more_values);
1979
1980 /* The following definitions come from libads/ndr.c  */
1981
1982 void ndr_print_ads_auth_flags(struct ndr_print *ndr, const char *name, uint32_t r);
1983 void ndr_print_ads_struct(struct ndr_print *ndr, const char *name, const struct ads_struct *r);
1984
1985 /* The following definitions come from libads/sasl.c  */
1986
1987 ADS_STATUS ads_sasl_bind(ADS_STRUCT *ads);
1988
1989 /* The following definitions come from libads/sasl_wrapping.c  */
1990
1991 ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads,
1992                                    const struct ads_saslwrap_ops *ops,
1993                                    void *private_data);
1994 ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads,
1995                                    const struct ads_saslwrap_ops *ops,
1996                                    void *private_data);
1997
1998 /* The following definitions come from libads/util.c  */
1999
2000 ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_principal);
2001 ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
2002                                        char **returned_principal);
2003
2004 /* The following definitions come from libgpo/gpo_filesync.c  */
2005
2006 NTSTATUS gpo_copy_file(TALLOC_CTX *mem_ctx,
2007                        struct cli_state *cli,
2008                        const char *nt_path,
2009                        const char *unix_path);
2010 NTSTATUS gpo_sync_directories(TALLOC_CTX *mem_ctx,
2011                               struct cli_state *cli,
2012                               const char *nt_path,
2013                               const char *local_path);
2014
2015 /* The following definitions come from libgpo/gpo_ini.c  */
2016
2017 NTSTATUS parse_gpt_ini(TALLOC_CTX *mem_ctx,
2018                        const char *filename,
2019                        uint32_t *version,
2020                        char **display_name);
2021
2022 /* The following definitions come from libgpo/gpo_reg.c  */
2023
2024 struct nt_user_token *registry_create_system_token(TALLOC_CTX *mem_ctx);
2025 WERROR gp_init_reg_ctx(TALLOC_CTX *mem_ctx,
2026                        const char *initial_path,
2027                        uint32_t desired_access,
2028                        const struct nt_user_token *token,
2029                        struct gp_registry_context **reg_ctx);
2030 void gp_free_reg_ctx(struct gp_registry_context *reg_ctx);
2031 WERROR gp_store_reg_subkey(TALLOC_CTX *mem_ctx,
2032                            const char *subkeyname,
2033                            struct registry_key *curr_key,
2034                            struct registry_key **new_key);
2035 WERROR gp_read_reg_subkey(TALLOC_CTX *mem_ctx,
2036                           struct gp_registry_context *reg_ctx,
2037                           const char *subkeyname,
2038                           struct registry_key **key);
2039 WERROR gp_store_reg_val_sz(TALLOC_CTX *mem_ctx,
2040                            struct registry_key *key,
2041                            const char *val_name,
2042                            const char *val);
2043 WERROR gp_read_reg_val_sz(TALLOC_CTX *mem_ctx,
2044                           struct registry_key *key,
2045                           const char *val_name,
2046                           const char **val);
2047 WERROR gp_reg_state_store(TALLOC_CTX *mem_ctx,
2048                           uint32_t flags,
2049                           const char *dn,
2050                           const struct nt_user_token *token,
2051                           struct GROUP_POLICY_OBJECT *gpo_list);
2052 WERROR gp_reg_state_read(TALLOC_CTX *mem_ctx,
2053                          uint32_t flags,
2054                          const DOM_SID *sid,
2055                          struct GROUP_POLICY_OBJECT **gpo_list);
2056 WERROR gp_secure_key(TALLOC_CTX *mem_ctx,
2057                      uint32_t flags,
2058                      struct registry_key *key,
2059                      const DOM_SID *sid);
2060 void dump_reg_val(int lvl, const char *direction,
2061                   const char *key, const char *subkey,
2062                   struct registry_value *val);
2063 void dump_reg_entry(uint32_t flags,
2064                     const char *dir,
2065                     struct gp_registry_entry *entry);
2066 void dump_reg_entries(uint32_t flags,
2067                       const char *dir,
2068                       struct gp_registry_entry *entries,
2069                       size_t num_entries);
2070 bool add_gp_registry_entry_to_array(TALLOC_CTX *mem_ctx,
2071                                     struct gp_registry_entry *entry,
2072                                     struct gp_registry_entry **entries,
2073                                     size_t *num);
2074 WERROR reg_apply_registry_entry(TALLOC_CTX *mem_ctx,
2075                                 struct registry_key *root_key,
2076                                 struct gp_registry_context *reg_ctx,
2077                                 struct gp_registry_entry *entry,
2078                                 const struct nt_user_token *token,
2079                                 uint32_t flags);
2080
2081
2082 #include "librpc/gen_ndr/ndr_dfs.h"
2083 #include "librpc/gen_ndr/ndr_dssetup.h"
2084 #include "librpc/gen_ndr/ndr_echo.h"
2085 #include "librpc/gen_ndr/ndr_eventlog.h"
2086 #include "librpc/gen_ndr/ndr_krb5pac.h"
2087 #include "librpc/gen_ndr/ndr_lsa.h"
2088 #include "librpc/gen_ndr/ndr_misc.h"
2089 #include "librpc/gen_ndr/ndr_netlogon.h"
2090 #include "librpc/gen_ndr/ndr_notify.h"
2091 #include "librpc/gen_ndr/ndr_ntsvcs.h"
2092 #include "librpc/gen_ndr/ndr_samr.h"
2093 #include "librpc/gen_ndr/ndr_security.h"
2094 #include "librpc/gen_ndr/ndr_srvsvc.h"
2095 #include "librpc/gen_ndr/ndr_svcctl.h"
2096 #include "librpc/gen_ndr/ndr_winreg.h"
2097 #include "librpc/gen_ndr/ndr_wkssvc.h"
2098
2099 #include "librpc/gen_ndr/srv_dfs.h"
2100 #include "librpc/gen_ndr/srv_dssetup.h"
2101 #include "librpc/gen_ndr/srv_echo.h"
2102 #include "librpc/gen_ndr/srv_eventlog.h"
2103 #include "librpc/gen_ndr/srv_initshutdown.h"
2104 #include "librpc/gen_ndr/srv_lsa.h"
2105 #include "librpc/gen_ndr/srv_netlogon.h"
2106 #include "librpc/gen_ndr/srv_ntsvcs.h"
2107 #include "librpc/gen_ndr/srv_samr.h"
2108 #include "librpc/gen_ndr/srv_srvsvc.h"
2109 #include "librpc/gen_ndr/srv_svcctl.h"
2110 #include "librpc/gen_ndr/srv_winreg.h"
2111 #include "librpc/gen_ndr/srv_wkssvc.h"
2112 #include "librpc/gen_ndr/srv_spoolss.h"
2113
2114 #include "librpc/ndr/libndr.h"
2115
2116 /* The following definitions come from librpc/ndr/util.c  */
2117
2118 enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r);
2119 enum ndr_err_code ndr_pull_server_id(struct ndr_pull *ndr, int ndr_flags, struct server_id *r);
2120 void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct server_id *r);
2121 enum ndr_err_code ndr_push_file_id(struct ndr_push *ndr, int ndr_flags, const struct file_id *r);
2122 enum ndr_err_code ndr_pull_file_id(struct ndr_pull *ndr, int ndr_flags, struct file_id *r);
2123 void ndr_print_file_id(struct ndr_print *ndr, const char *name, const struct file_id *r);
2124 _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b);
2125 _PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss);
2126 const char *ndr_errstr(enum ndr_err_code err);
2127
2128 /* The following definitions come from librpc/ndr/sid.c  */
2129
2130 char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
2131
2132 /* The following definitions come from librpc/rpc/binding.c  */
2133
2134 const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
2135 _PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b);
2136 _PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out);
2137 _PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor,
2138                                             struct ndr_syntax_id *syntax);
2139 const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
2140 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
2141 _PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(const struct epm_tower *tower);
2142 _PUBLIC_ const char *derpc_transport_string_by_transport(enum dcerpc_transport_t t);
2143 _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 
2144                                    struct epm_tower *tower, 
2145                                    struct dcerpc_binding **b_out);
2146 _PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx,
2147                                              const struct dcerpc_binding *binding,
2148                                              struct epm_tower *tower);
2149
2150 /* The following definitions come from librpc/rpc/dcerpc.c  */
2151
2152 struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p, const struct GUID *object, 
2153                                             const struct ndr_interface_table *table, uint32_t opnum, 
2154                                             TALLOC_CTX *mem_ctx, void *r);
2155 NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req);
2156 _PUBLIC_ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, struct dcerpc_pipe **pp, 
2157                                       const char *binding_string, const struct ndr_interface_table *table, 
2158                                       struct cli_credentials *credentials, struct event_context *ev, 
2159                                       struct loadparm_context *lp_ctx);
2160
2161 /* The following definitions come from libsmb/cliconnect.c  */
2162
2163 ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user, 
2164                               const char *pass, const char *user_domain,
2165                                     const char * dest_realm);
2166
2167 NTSTATUS cli_session_setup(struct cli_state *cli,
2168                            const char *user,
2169                            const char *pass, int passlen,
2170                            const char *ntpass, int ntpasslen,
2171                            const char *workgroup);
2172 struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
2173                                                 struct event_context *ev,
2174                                                 struct cli_state *cli);
2175 NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
2176 bool cli_ulogoff(struct cli_state *cli);
2177 struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
2178                                       struct event_context *ev,
2179                                       struct cli_state *cli,
2180                                       const char *share, const char *dev,
2181                                       const char *pass, int passlen);
2182 NTSTATUS cli_tcon_andx_recv(struct tevent_req *req);
2183 NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
2184                        const char *dev, const char *pass, int passlen);
2185 bool cli_tdis(struct cli_state *cli);
2186 void cli_negprot_sendsync(struct cli_state *cli);
2187 NTSTATUS cli_negprot(struct cli_state *cli);
2188 struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
2189                                     struct event_context *ev,
2190                                     struct cli_state *cli);
2191 NTSTATUS cli_negprot_recv(struct tevent_req *req);
2192 bool cli_session_request(struct cli_state *cli,
2193                          struct nmb_name *calling, struct nmb_name *called);
2194 NTSTATUS cli_connect(struct cli_state *cli,
2195                 const char *host,
2196                 struct sockaddr_storage *dest_ss);
2197 NTSTATUS cli_start_connection(struct cli_state **output_cli, 
2198                               const char *my_name, 
2199                               const char *dest_host, 
2200                               struct sockaddr_storage *dest_ss, int port,
2201                               int signing_state, int flags,
2202                               bool *retry) ;
2203 NTSTATUS cli_full_connection(struct cli_state **output_cli, 
2204                              const char *my_name, 
2205                              const char *dest_host, 
2206                              struct sockaddr_storage *dest_ss, int port,
2207                              const char *service, const char *service_type,
2208                              const char *user, const char *domain, 
2209                              const char *password, int flags,
2210                              int signing_state,
2211                              bool *retry) ;
2212 bool attempt_netbios_session_request(struct cli_state **ppcli, const char *srchost, const char *desthost,
2213                                      struct sockaddr_storage *pdest_ss);
2214 NTSTATUS cli_raw_tcon(struct cli_state *cli, 
2215                       const char *service, const char *pass, const char *dev,
2216                       uint16 *max_xmit, uint16 *tid);
2217 struct cli_state *get_ipc_connect(char *server,
2218                                 struct sockaddr_storage *server_ss,
2219                                 const struct user_auth_info *user_info);
2220 struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
2221                                 struct ip_service *mb_ip,
2222                                 const struct user_auth_info *user_info,
2223                                 char **pp_workgroup_out);
2224 struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
2225                                         const struct user_auth_info *user_info,
2226                                         char **pp_workgroup_out);
2227
2228 /* The following definitions come from libsmb/clidfs.c  */
2229
2230 NTSTATUS cli_cm_force_encryption(struct cli_state *c,
2231                         const char *username,
2232                         const char *password,
2233                         const char *domain,
2234                         const char *sharename);
2235 struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
2236                                 struct cli_state *referring_cli,
2237                                 const char *server,
2238                                 const char *share,
2239                                 const struct user_auth_info *auth_info,
2240                                 bool show_hdr,
2241                                 bool force_encrypt,
2242                                 int max_protocol,
2243                                 int port,
2244                                 int name_type);
2245 void cli_cm_display(const struct cli_state *c);
2246 bool cli_dfs_get_referral(TALLOC_CTX *ctx,
2247                         struct cli_state *cli,
2248                         const char *path,
2249                         CLIENT_DFS_REFERRAL**refs,
2250                         size_t *num_refs,
2251                         uint16 *consumed);
2252 bool cli_resolve_path(TALLOC_CTX *ctx,
2253                         const char *mountpt,
2254                         const struct user_auth_info *dfs_auth_info,
2255                         struct cli_state *rootcli,
2256                         const char *path,
2257                         struct cli_state **targetcli,
2258                         char **pp_targetpath);
2259
2260 /* The following definitions come from libsmb/clidgram.c  */
2261
2262 bool cli_send_mailslot(struct messaging_context *msg_ctx,
2263                        bool unique, const char *mailslot,
2264                        uint16 priority,
2265                        char *buf, int len,
2266                        const char *srcname, int src_type,
2267                        const char *dstname, int dest_type,
2268                        const struct sockaddr_storage *dest_ss);
2269 bool send_getdc_request(TALLOC_CTX *mem_ctx,
2270                         struct messaging_context *msg_ctx,
2271                         struct sockaddr_storage *dc_ss,
2272                         const char *domain_name,
2273                         const DOM_SID *sid,
2274                         uint32_t nt_version);
2275 bool receive_getdc_response(TALLOC_CTX *mem_ctx,
2276                             struct sockaddr_storage *dc_ss,
2277                             const char *domain_name,
2278                             uint32_t *nt_version,
2279                             const char **dc_name,
2280                             struct netlogon_samlogon_response **reply);
2281
2282 /* The following definitions come from libsmb/clientgen.c  */
2283
2284 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
2285 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
2286 void cli_set_port(struct cli_state *cli, int port);
2287 bool cli_state_seqnum_persistent(struct cli_state *cli,
2288                                  uint16_t mid);
2289 bool cli_state_seqnum_remove(struct cli_state *cli,
2290                              uint16_t mid);
2291 bool cli_receive_smb(struct cli_state *cli);
2292 ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len);
2293 bool cli_receive_smb_readX_header(struct cli_state *cli);
2294 bool cli_send_smb(struct cli_state *cli);
2295 bool cli_send_smb_direct_writeX(struct cli_state *cli,
2296                                 const char *p,
2297                                 size_t extradata);
2298 void cli_setup_packet_buf(struct cli_state *cli, char *buf);
2299 void cli_setup_packet(struct cli_state *cli);
2300 void cli_setup_bcc(struct cli_state *cli, void *p);
2301 NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
2302 NTSTATUS cli_set_username(struct cli_state *cli, const char *username);
2303 NTSTATUS cli_set_password(struct cli_state *cli, const char *password);
2304 NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password);
2305 struct cli_state *cli_initialise(void);
2306 struct cli_state *cli_initialise_ex(int signing_state);
2307 void cli_nt_pipes_close(struct cli_state *cli);
2308 void cli_shutdown(struct cli_state *cli);
2309 void cli_sockopt(struct cli_state *cli, const char *options);
2310 uint16 cli_setpid(struct cli_state *cli, uint16 pid);
2311 bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
2312 bool cli_send_keepalive(struct cli_state *cli);
2313 struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
2314                                  struct cli_state *cli, uint16_t num_echos,
2315                                  DATA_BLOB data);
2316 NTSTATUS cli_echo_recv(struct tevent_req *req);
2317 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
2318 bool cli_ucs2(struct cli_state *cli);
2319 bool is_andx_req(uint8_t cmd);
2320
2321 /* The following definitions come from libsmb/clierror.c  */
2322
2323 const char *cli_errstr(struct cli_state *cli);
2324 NTSTATUS cli_nt_error(struct cli_state *cli);
2325 void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode);
2326 int cli_errno(struct cli_state *cli);
2327 bool cli_is_error(struct cli_state *cli);
2328 bool cli_is_nt_error(struct cli_state *cli);
2329 bool cli_is_dos_error(struct cli_state *cli);
2330 NTSTATUS cli_get_nt_error(struct cli_state *cli);
2331 void cli_set_nt_error(struct cli_state *cli, NTSTATUS status);
2332 void cli_reset_error(struct cli_state *cli);
2333
2334 /* The following definitions come from libsmb/clifile.c  */
2335
2336 uint32_t unix_perms_to_wire(mode_t perms);
2337 mode_t wire_perms_to_unix(uint32_t perms);
2338 bool cli_unix_getfacl(struct cli_state *cli, const char *name, size_t *prb_size, char **retbuf);
2339 bool cli_unix_stat(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbuf);
2340 bool cli_unix_symlink(struct cli_state *cli, const char *oldname, const char *newname);
2341 bool cli_unix_hardlink(struct cli_state *cli, const char *oldname, const char *newname);
2342 bool cli_unix_chmod(struct cli_state *cli, const char *fname, mode_t mode);
2343 bool cli_unix_chown(struct cli_state *cli, const char *fname, uid_t uid, gid_t gid);
2344 struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
2345                                 struct event_context *ev,
2346                                 struct cli_state *cli,
2347                                 const char *fname_src,
2348                                 const char *fname_dst);
2349 NTSTATUS cli_rename_recv(struct tevent_req *req);
2350 NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
2351 struct tevent_req *cli_ntrename_send(TALLOC_CTX *mem_ctx,
2352                                 struct event_context *ev,
2353                                 struct cli_state *cli,
2354                                 const char *fname_src,
2355                                 const char *fname_dst);
2356 NTSTATUS cli_ntrename_recv(struct tevent_req *req);
2357 NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
2358
2359 struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
2360                                 struct event_context *ev,
2361                                 struct cli_state *cli,
2362                                 const char *fname_src,
2363                                 const char *fname_dst);
2364 NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
2365 NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
2366
2367 struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
2368                                 struct event_context *ev,
2369                                 struct cli_state *cli,
2370                                 const char *fname,
2371                                 uint16_t mayhave_attrs);
2372 NTSTATUS cli_unlink_recv(struct tevent_req *req);
2373 NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
2374
2375 struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
2376                                   struct event_context *ev,
2377                                   struct cli_state *cli,
2378                                   const char *dname);
2379 NTSTATUS cli_mkdir_recv(struct tevent_req *req);
2380 NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname);
2381 struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
2382                                   struct event_context *ev,
2383                                   struct cli_state *cli,
2384                                   const char *dname);
2385 NTSTATUS cli_rmdir_recv(struct tevent_req *req);
2386 NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
2387 int cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
2388 struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
2389                                      struct event_context *ev,
2390                                      struct cli_state *cli,
2391                                      const char *fname,
2392                                      uint32_t CreatFlags,
2393                                      uint32_t DesiredAccess,
2394                                      uint32_t FileAttributes,
2395                                      uint32_t ShareAccess,
2396                                      uint32_t CreateDisposition,
2397                                      uint32_t CreateOptions,
2398                                      uint8_t SecurityFlags);
2399 NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum);
2400 NTSTATUS cli_ntcreate(struct cli_state *cli,
2401                       const char *fname,
2402                       uint32_t CreatFlags,
2403                       uint32_t DesiredAccess,
2404                       uint32_t FileAttributes,
2405                       uint32_t ShareAccess,
2406                       uint32_t CreateDisposition,
2407                       uint32_t CreateOptions,
2408                       uint8_t SecurityFlags,
2409                       uint16_t *pfid);
2410 uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
2411                             size_t str_len, size_t *pconverted_size);
2412 struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
2413                                    struct event_context *ev,
2414                                    struct cli_state *cli, const char *fname,
2415                                    int flags, int share_mode,
2416                                    struct tevent_req **psmbreq);
2417 struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
2418                                  struct cli_state *cli, const char *fname,
2419                                  int flags, int share_mode);
2420 NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum);
2421 NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
2422 struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
2423                                     struct event_context *ev,
2424                                     struct cli_state *cli, uint16_t fnum,
2425                                     struct tevent_req **psubreq);
2426 struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
2427                                   struct event_context *ev,
2428                                   struct cli_state *cli, uint16_t fnum);
2429 NTSTATUS cli_close_recv(struct tevent_req *req);
2430 NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
2431 bool cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
2432 NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
2433                       uint32_t offset, uint32_t len,
2434                       int timeout, unsigned char locktype);
2435 bool cli_lock(struct cli_state *cli, uint16_t fnum,
2436               uint32_t offset, uint32_t len, int timeout, enum brl_type lock_type);
2437 bool cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
2438 bool cli_lock64(struct cli_state *cli, uint16_t fnum,
2439                 uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type);
2440 bool cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
2441 bool cli_posix_lock(struct cli_state *cli, uint16_t fnum,
2442                         uint64_t offset, uint64_t len,
2443                         bool wait_lock, enum brl_type lock_type);
2444 bool cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
2445 bool cli_posix_getlock(struct cli_state *cli, uint16_t fnum, uint64_t *poffset, uint64_t *plen);
2446 struct tevent_req *cli_getattrE_send(TALLOC_CTX *mem_ctx,
2447                                 struct event_context *ev,
2448                                 struct cli_state *cli,
2449                                 uint16_t fnum);
2450 NTSTATUS cli_getattrE_recv(struct tevent_req *req,
2451                         uint16_t *attr,
2452                         SMB_OFF_T *size,
2453                         time_t *change_time,
2454                         time_t *access_time,
2455                         time_t *write_time);
2456 NTSTATUS cli_getattrE(struct cli_state *cli,
2457                         uint16_t fnum,
2458                         uint16_t *attr,
2459                         SMB_OFF_T *size,
2460                         time_t *change_time,
2461                         time_t *access_time,
2462                         time_t *write_time);
2463 struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
2464                                 struct event_context *ev,
2465                                 struct cli_state *cli,
2466                                 uint16_t fnum,
2467                                 time_t change_time,
2468                                 time_t access_time,
2469                                 time_t write_time);
2470 NTSTATUS cli_setattrE_recv(struct tevent_req *req);
2471 NTSTATUS cli_setattrE(struct cli_state *cli,
2472                         uint16_t fnum,
2473                         time_t change_time,
2474                         time_t access_time,
2475                         time_t write_time);
2476 struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
2477                                 struct event_context *ev,
2478                                 struct cli_state *cli,
2479                                 const char *fname);
2480 NTSTATUS cli_getatr_recv(struct tevent_req *req,
2481                                 uint16_t *attr,
2482                                 SMB_OFF_T *size,
2483                                 time_t *write_time);
2484 NTSTATUS cli_getatr(struct cli_state *cli,
2485                         const char *fname,
2486                         uint16_t *attr,
2487                         SMB_OFF_T *size,
2488                         time_t *write_time);
2489 struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
2490                                 struct event_context *ev,
2491                                 struct cli_state *cli,
2492                                 const char *fname,
2493                                 uint16_t attr,
2494                                 time_t mtime);
2495 NTSTATUS cli_setatr_recv(struct tevent_req *req);
2496 NTSTATUS cli_setatr(struct cli_state *cli,
2497                 const char *fname,
2498                 uint16_t attr,
2499                 time_t mtime);
2500 struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
2501                                   struct event_context *ev,
2502                                   struct cli_state *cli,
2503                                   const char *fname);
2504 NTSTATUS cli_chkpath_recv(struct tevent_req *req);
2505 NTSTATUS cli_chkpath(struct cli_state *cli, const char *path);
2506 struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
2507                                   struct event_context *ev,
2508                                   struct cli_state *cli);
2509 NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
2510                           int *avail);
2511 NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
2512 int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path);
2513 NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
2514 bool cli_set_ea_path(struct cli_state *cli, const char *path, const char *ea_name, const char *ea_val, size_t ea_len);
2515 bool cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum, const char *ea_name, const char *ea_val, size_t ea_len);
2516 bool cli_get_ea_list_path(struct cli_state *cli, const char *path,
2517                 TALLOC_CTX *ctx,
2518                 size_t *pnum_eas,
2519                 struct ea_struct **pea_list);
2520 bool cli_get_ea_list_fnum(struct cli_state *cli, uint16_t fnum,
2521                 TALLOC_CTX *ctx,
2522                 size_t *pnum_eas,
2523                 struct ea_struct **pea_list);
2524 int cli_posix_open(struct cli_state *cli, const char *fname, int flags, mode_t mode);
2525 int cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
2526
2527 struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
2528                                         struct event_context *ev,
2529                                         struct cli_state *cli,
2530                                         const char *fname);
2531 NTSTATUS cli_posix_unlink_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2532 NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname);
2533
2534 struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
2535                                         struct event_context *ev,
2536                                         struct cli_state *cli,
2537                                         const char *fname);
2538 NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2539 NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname);
2540
2541 /* The following definitions come from libsmb/clifsinfo.c  */
2542
2543 bool cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor, uint16 *pminor,
2544                                         uint32 *pcaplow, uint32 *pcaphigh);
2545 bool cli_set_unix_extensions_capabilities(struct cli_state *cli, uint16 major, uint16 minor,
2546                                         uint32 caplow, uint32 caphigh);
2547 bool cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr);
2548 bool cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint32 *pserial_number);
2549 bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate);
2550 bool cli_get_fs_full_size_info(struct cli_state *cli,
2551                                uint64_t *total_allocation_units,
2552                                uint64_t *caller_allocation_units,
2553                                uint64_t *actual_allocation_units,
2554                                uint64_t *sectors_per_allocation_unit,
2555                                uint64_t *bytes_per_sector);
2556 bool cli_get_posix_fs_info(struct cli_state *cli,
2557                            uint32 *optimal_transfer_size,
2558                            uint32 *block_size,
2559                            uint64_t *total_blocks,
2560                            uint64_t *blocks_available,
2561                            uint64_t *user_blocks_available,
2562                            uint64_t *total_file_nodes,
2563                            uint64_t *free_file_nodes,
2564                            uint64_t *fs_identifier);
2565 NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli, 
2566                                 const char *user,
2567                                 const char *pass,
2568                                 const char *domain);
2569 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli);
2570 NTSTATUS cli_force_encryption(struct cli_state *c,
2571                         const char *username,
2572                         const char *password,
2573                         const char *domain);
2574
2575 /* The following definitions come from libsmb/clikrb5.c  */
2576
2577 bool unwrap_edata_ntstatus(TALLOC_CTX *mem_ctx, 
2578                            DATA_BLOB *edata, 
2579                            DATA_BLOB *edata_out);
2580 bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_pac_data);
2581 int cli_krb5_get_ticket(const char *principal, time_t time_offset, 
2582                         DATA_BLOB *ticket, DATA_BLOB *session_key_krb5, 
2583                         uint32 extra_ap_opts, const char *ccname, 
2584                         time_t *tgs_expire);
2585
2586 /* The following definitions come from libsmb/clilist.c  */
2587
2588 int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
2589                  void (*fn)(const char *, file_info *, const char *, void *), void *state);
2590 int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
2591                  void (*fn)(const char *, file_info *, const char *, void *), void *state);
2592 int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
2593              void (*fn)(const char *, file_info *, const char *, void *), void *state);
2594
2595 /* The following definitions come from libsmb/climessage.c  */
2596
2597 int cli_message_start_build(struct cli_state *cli, const char *host, const char *username);
2598 bool cli_message_start(struct cli_state *cli, const char *host, const char *username,
2599                               int *grp);
2600 int cli_message_text_build(struct cli_state *cli, const char *msg, int len, int grp);
2601 bool cli_message_text(struct cli_state *cli, const char *msg, int len, int grp);
2602 int cli_message_end_build(struct cli_state *cli, int grp);
2603 bool cli_message_end(struct cli_state *cli, int grp);
2604
2605 /* The following definitions come from libsmb/clioplock.c  */
2606
2607 struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
2608                                        struct tevent_context *ev,
2609                                        struct cli_state *cli,
2610                                        uint16_t fnum, uint8_t level);
2611 NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
2612 NTSTATUS cli_oplock_ack(struct cli_state *cli, uint16_t fnum, unsigned char level);
2613 void cli_oplock_handler(struct cli_state *cli, 
2614                         NTSTATUS (*handler)(struct cli_state *, uint16_t, unsigned char));
2615
2616 /* The following definitions come from libsmb/cliprint.c  */
2617
2618 int cli_print_queue(struct cli_state *cli,
2619                     void (*fn)(struct print_job_info *));
2620 int cli_printjob_del(struct cli_state *cli, int job);
2621 int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_mode);
2622 bool cli_spl_close(struct cli_state *cli, uint16_t fnum);
2623
2624 /* The following definitions come from libsmb/cliquota.c  */
2625
2626 NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
2627 void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
2628 bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
2629 bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
2630 bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST **pqt_list);
2631 bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
2632 bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
2633 void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric));
2634 void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric));
2635
2636 /* The following definitions come from libsmb/clirap.c  */
2637
2638 bool cli_api(struct cli_state *cli,
2639              char *param, int prcnt, int mprcnt,
2640              char *data, int drcnt, int mdrcnt,
2641              char **rparam, unsigned int *rprcnt,
2642              char **rdata, unsigned int *rdrcnt);
2643 bool cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation);
2644 int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state);
2645 bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
2646                        void (*fn)(const char *, uint32, const char *, void *),
2647                        void *state);
2648 bool cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
2649                              const char *old_password);
2650 bool cli_qpathinfo(struct cli_state *cli,
2651                         const char *fname,
2652                         time_t *change_time,
2653                         time_t *access_time,
2654                         time_t *write_time,
2655                         SMB_OFF_T *size,
2656                         uint16 *mode);
2657 bool cli_setpathinfo(struct cli_state *cli, const char *fname,
2658                      time_t create_time,
2659                      time_t access_time,
2660                      time_t write_time,
2661                      time_t change_time,
2662                      uint16 mode);
2663 bool cli_qpathinfo2(struct cli_state *cli, const char *fname,
2664                     struct timespec *create_time,
2665                     struct timespec *access_time,
2666                     struct timespec *write_time,
2667                     struct timespec *change_time,
2668                     SMB_OFF_T *size, uint16 *mode,
2669                     SMB_INO_T *ino);
2670 bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
2671                            TALLOC_CTX *mem_ctx,
2672                            unsigned int *pnum_streams,
2673                            struct stream_struct **pstreams);
2674 bool cli_qfilename(struct cli_state *cli, uint16_t fnum, char *name, size_t namelen);
2675 bool cli_qfileinfo(struct cli_state *cli, uint16_t fnum,
2676                    uint16 *mode, SMB_OFF_T *size,
2677                    struct timespec *create_time,
2678                    struct timespec *access_time,
2679                    struct timespec *write_time,
2680                    struct timespec *change_time,
2681                    SMB_INO_T *ino);
2682 bool cli_qpathinfo_basic( struct cli_state *cli, const char *name,
2683                           SMB_STRUCT_STAT *sbuf, uint32 *attributes );
2684 bool cli_qfileinfo_test(struct cli_state *cli, uint16_t fnum, int level, char **poutdata, uint32 *poutlen);
2685 NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstring alt_name);
2686
2687 /* The following definitions come from libsmb/clirap2.c  */
2688
2689 int cli_NetGroupDelete(struct cli_state *cli, const char *group_name);
2690 int cli_NetGroupAdd(struct cli_state *cli, RAP_GROUP_INFO_1 *grinfo);
2691 int cli_RNetGroupEnum(struct cli_state *cli, void (*fn)(const char *, const char *, void *), void *state);
2692 int cli_RNetGroupEnum0(struct cli_state *cli,
2693                        void (*fn)(const char *, void *),
2694                        void *state);
2695 int cli_NetGroupDelUser(struct cli_state * cli, const char *group_name, const char *user_name);
2696 int cli_NetGroupAddUser(struct cli_state * cli, const char *group_name, const char *user_name);
2697 int cli_NetGroupGetUsers(struct cli_state * cli, const char *group_name, void (*fn)(const char *, void *), void *state );
2698 int cli_NetUserGetGroups(struct cli_state * cli, const char *user_name, void (*fn)(const char *, void *), void *state );
2699 int cli_NetUserDelete(struct cli_state *cli, const char * user_name );
2700 int cli_NetUserAdd(struct cli_state *cli, RAP_USER_INFO_1 * userinfo );
2701 int cli_RNetUserEnum(struct cli_state *cli, void (*fn)(const char *, const char *, const char *, const char *, void *), void *state);
2702 int cli_RNetUserEnum0(struct cli_state *cli,
2703                       void (*fn)(const char *, void *),
2704                       void *state);
2705 int cli_NetFileClose(struct cli_state *cli, uint32 file_id );
2706 int cli_NetFileGetInfo(struct cli_state *cli, uint32 file_id, void (*fn)(const char *, const char *, uint16, uint16, uint32));
2707 int cli_NetFileEnum(struct cli_state *cli, const char * user,
2708                     const char * base_path,
2709                     void (*fn)(const char *, const char *, uint16, uint16,
2710                                uint32));
2711 int cli_NetShareAdd(struct cli_state *cli, RAP_SHARE_INFO_2 * sinfo );
2712 int cli_NetShareDelete(struct cli_state *cli, const char * share_name );
2713 bool cli_get_pdc_name(struct cli_state *cli, const char *workgroup, char **pdc_name);
2714 bool cli_get_server_domain(struct cli_state *cli);
2715 bool cli_get_server_type(struct cli_state *cli, uint32 *pstype);
2716 bool cli_get_server_name(TALLOC_CTX *mem_ctx, struct cli_state *cli,
2717                          char **servername);
2718 bool cli_ns_check_server_type(struct cli_state *cli, char *workgroup, uint32 stype);
2719 bool cli_NetWkstaUserLogoff(struct cli_state *cli, const char *user, const char *workstation);
2720 int cli_NetPrintQEnum(struct cli_state *cli,
2721                 void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16),
2722                 void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,uint,uint,const char*));
2723 int cli_NetPrintQGetInfo(struct cli_state *cli, const char *printer,
2724         void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16),
2725         void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,uint,uint,const char*));
2726 int cli_RNetServiceEnum(struct cli_state *cli, void (*fn)(const char *, const char *, void *), void *state);
2727 int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16, uint16, uint16, uint, uint, uint, char *));
2728 int cli_NetSessionGetInfo(struct cli_state *cli, const char *workstation,
2729                 void (*fn)(const char *, const char *, uint16, uint16, uint16, uint, uint, uint, const char *));
2730 int cli_NetSessionDel(struct cli_state *cli, const char *workstation);
2731 int cli_NetConnectionEnum(struct cli_state *cli, const char *qualifier,
2732                         void (*fn)(uint16_t conid, uint16_t contype,
2733                                 uint16_t numopens, uint16_t numusers,
2734                                 uint32_t contime, const char *username,
2735                                 const char *netname));
2736
2737 /* The following definitions come from libsmb/clireadwrite.c  */
2738
2739 struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
2740                                         struct event_context *ev,
2741                                         struct cli_state *cli, uint16_t fnum,
2742                                         off_t offset, size_t size,
2743                                         struct tevent_req **psmbreq);
2744 struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
2745                                       struct event_context *ev,
2746                                       struct cli_state *cli, uint16_t fnum,
2747                                       off_t offset, size_t size);
2748 NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
2749                             uint8_t **rcvbuf);
2750 struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
2751                                  struct event_context *ev,
2752                                  struct cli_state *cli,
2753                                  uint16_t fnum, off_t start_offset,
2754                                  SMB_OFF_T size, size_t window_size,
2755                                  NTSTATUS (*sink)(char *buf, size_t n,
2756                                                   void *priv),
2757                                  void *priv);
2758 NTSTATUS cli_pull_recv(struct tevent_req *req, SMB_OFF_T *received);
2759 NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
2760                   off_t start_offset, SMB_OFF_T size, size_t window_size,
2761                   NTSTATUS (*sink)(char *buf, size_t n, void *priv),
2762                   void *priv, SMB_OFF_T *received);
2763 ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
2764                  off_t offset, size_t size);
2765 ssize_t cli_readraw(struct cli_state *cli, uint16_t fnum, char *buf, off_t offset, size_t size);
2766 ssize_t cli_write(struct cli_state *cli,
2767                  uint16_t fnum, uint16 write_mode,
2768                  const char *buf, off_t offset, size_t size);
2769 ssize_t cli_smbwrite(struct cli_state *cli,
2770                      uint16_t fnum, char *buf, off_t offset, size_t size1);
2771 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
2772                                          struct event_context *ev,
2773                                          struct cli_state *cli, uint16_t fnum,
2774                                          uint16_t mode, const uint8_t *buf,
2775                                          off_t offset, size_t size,
2776                                          struct tevent_req **reqs_before,
2777                                          int num_reqs_before,
2778                                          struct tevent_req **psmbreq);
2779 struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
2780                                        struct event_context *ev,
2781                                        struct cli_state *cli, uint16_t fnum,
2782                                        uint16_t mode, const uint8_t *buf,
2783                                        off_t offset, size_t size);
2784 NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
2785
2786 struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
2787                                  struct cli_state *cli,
2788                                  uint16_t fnum, uint16_t mode,
2789                                  off_t start_offset, size_t window_size,
2790                                  size_t (*source)(uint8_t *buf, size_t n,
2791                                                   void *priv),
2792                                  void *priv);
2793 NTSTATUS cli_push_recv(struct tevent_req *req);
2794 NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
2795                   off_t start_offset, size_t window_size,
2796                   size_t (*source)(uint8_t *buf, size_t n, void *priv),
2797                   void *priv);
2798
2799 /* The following definitions come from libsmb/clisecdesc.c  */
2800
2801 SEC_DESC *cli_query_secdesc(struct cli_state *cli, uint16_t fnum, 
2802                             TALLOC_CTX *mem_ctx);
2803 bool cli_set_secdesc(struct cli_state *cli, uint16_t fnum, SEC_DESC *sd);
2804
2805 /* The following definitions come from libsmb/clispnego.c  */
2806
2807 DATA_BLOB spnego_gen_negTokenInit(char guid[16], 
2808                                   const char *OIDs[], 
2809                                   const char *principal);
2810 DATA_BLOB gen_negTokenInit(const char *OID, DATA_BLOB blob);
2811 bool spnego_parse_negTokenInit(DATA_BLOB blob,
2812                                char *OIDs[ASN1_MAX_OIDS],
2813                                char **principal);
2814 DATA_BLOB gen_negTokenTarg(const char *OIDs[], DATA_BLOB blob);
2815 bool parse_negTokenTarg(DATA_BLOB blob, char *OIDs[ASN1_MAX_OIDS], DATA_BLOB *secblob);
2816 DATA_BLOB spnego_gen_krb5_wrap(const DATA_BLOB ticket, const uint8 tok_id[2]);
2817 bool spnego_parse_krb5_wrap(DATA_BLOB blob, DATA_BLOB *ticket, uint8 tok_id[2]);
2818 int spnego_gen_negTokenTarg(const char *principal, int time_offset, 
2819                             DATA_BLOB *targ, 
2820                             DATA_BLOB *session_key_krb5, uint32 extra_ap_opts,
2821                             time_t *expire_time);
2822 bool spnego_parse_challenge(const DATA_BLOB blob,
2823                             DATA_BLOB *chal1, DATA_BLOB *chal2);
2824 DATA_BLOB spnego_gen_auth(DATA_BLOB blob);
2825 bool spnego_parse_auth(DATA_BLOB blob, DATA_BLOB *auth);
2826 DATA_BLOB spnego_gen_auth_response(DATA_BLOB *reply, NTSTATUS nt_status,
2827                                    const char *mechOID);
2828 bool spnego_parse_auth_response(DATA_BLOB blob, NTSTATUS nt_status,
2829                                 const char *mechOID,
2830                                 DATA_BLOB *auth);
2831
2832 /* The following definitions come from libsmb/clistr.c  */
2833
2834 size_t clistr_push_fn(const char *function,
2835                         unsigned int line,
2836                         struct cli_state *cli,
2837                         void *dest,
2838                         const char *src,
2839                         int dest_len,
2840                         int flags);
2841 size_t clistr_pull_fn(const char *function,
2842                         unsigned int line,
2843                         const char *inbuf,
2844                         char *dest,
2845                         const void *src,
2846                         int dest_len,
2847                         int src_len,
2848                         int flags);
2849 size_t clistr_pull_talloc_fn(const char *function,
2850                                 unsigned int line,
2851                                 TALLOC_CTX *ctx,
2852                                 const char *inbuf,
2853                                 char **pp_dest,
2854                                 const void *src,
2855                                 int src_len,
2856                                 int flags);
2857 size_t clistr_align_out(struct cli_state *cli, const void *p, int flags);
2858 size_t clistr_align_in(struct cli_state *cli, const void *p, int flags);
2859
2860 /* The following definitions come from libsmb/clitrans.c  */
2861
2862 bool cli_send_trans(struct cli_state *cli, int trans,
2863                     const char *pipe_name,
2864                     int fid, int flags,
2865                     uint16 *setup, unsigned int lsetup, unsigned int msetup,
2866                     const char *param, unsigned int lparam, unsigned int mparam,
2867                     const char *data, unsigned int ldata, unsigned int mdata);
2868 bool cli_receive_trans(struct cli_state *cli,int trans,
2869                               char **param, unsigned int *param_len,
2870                               char **data, unsigned int *data_len);
2871 bool cli_send_nt_trans(struct cli_state *cli,
2872                        int function,
2873                        int flags,
2874                        uint16 *setup, unsigned int lsetup, unsigned int msetup,
2875                        char *param, unsigned int lparam, unsigned int mparam,
2876                        char *data, unsigned int ldata, unsigned int mdata);
2877 bool cli_receive_nt_trans(struct cli_state *cli,
2878                           char **param, unsigned int *param_len,
2879                           char **data, unsigned int *data_len);
2880 struct tevent_req *cli_trans_send(
2881         TALLOC_CTX *mem_ctx, struct event_context *ev,
2882         struct cli_state *cli, uint8_t cmd,
2883         const char *pipe_name, uint16_t fid, uint16_t function, int flags,
2884         uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
2885         uint8_t *param, uint32_t num_param, uint32_t max_param,
2886         uint8_t *data, uint32_t num_data, uint32_t max_data);
2887 NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
2888                         uint16_t **setup, uint8_t *num_setup,
2889                         uint8_t **param, uint32_t *num_param,
2890                         uint8_t **data, uint32_t *num_data);
2891 NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
2892                    uint8_t trans_cmd,
2893                    const char *pipe_name, uint16_t fid, uint16_t function,
2894                    int flags,
2895                    uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
2896                    uint8_t *param, uint32_t num_param, uint32_t max_param,
2897                    uint8_t *data, uint32_t num_data, uint32_t max_data,
2898                    uint16_t **rsetup, uint8_t *num_rsetup,
2899                    uint8_t **rparam, uint32_t *num_rparam,
2900                    uint8_t **rdata, uint32_t *num_rdata);
2901
2902 /* The following definitions come from libsmb/conncache.c  */
2903
2904 NTSTATUS check_negative_conn_cache_timeout( const char *domain, const char *server, unsigned int failed_cache_timeout );
2905 NTSTATUS check_negative_conn_cache( const char *domain, const char *server);
2906 void add_failed_connection_entry(const char *domain, const char *server, NTSTATUS result) ;
2907 void delete_negative_conn_cache(const char *domain, const char *server);
2908 void flush_negative_conn_cache( void );
2909 void flush_negative_conn_cache_for_domain(const char *domain);
2910
2911 /* The following definitions come from ../librpc/rpc/dcerpc_error.c  */
2912
2913 const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code);
2914
2915 /* The following definitions come from libsmb/dsgetdcname.c  */
2916
2917 void debug_dsdcinfo_flags(int lvl, uint32_t flags);
2918 NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
2919                      struct messaging_context *msg_ctx,
2920                      const char *domain_name,
2921                      struct GUID *domain_guid,
2922                      const char *site_name,
2923                      uint32_t flags,
2924                      struct netr_DsRGetDCNameInfo **info);
2925
2926 /* The following definitions come from libsmb/errormap.c  */
2927
2928 NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode);
2929 void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32 *ecode);
2930 NTSTATUS werror_to_ntstatus(WERROR error);
2931 WERROR ntstatus_to_werror(NTSTATUS error);
2932 NTSTATUS map_nt_error_from_gss(uint32 gss_maj, uint32 minor);
2933
2934 /* The following definitions come from libsmb/namecache.c  */
2935
2936 bool namecache_enable(void);
2937 bool namecache_store(const char *name,
2938                         int name_type,
2939                         int num_names,
2940                         struct ip_service *ip_list);
2941 bool namecache_fetch(const char *name,
2942                         int name_type,
2943                         struct ip_service **ip_list,
2944                         int *num_names);
2945 bool namecache_delete(const char *name, int name_type);
2946 void namecache_flush(void);
2947 bool namecache_status_store(const char *keyname, int keyname_type,
2948                 int name_type, const struct sockaddr_storage *keyip,
2949                 const char *srvname);
2950 bool namecache_status_fetch(const char *keyname,
2951                                 int keyname_type,
2952                                 int name_type,
2953                                 const struct sockaddr_storage *keyip,
2954                                 char *srvname_out);
2955
2956 /* The following definitions come from libsmb/namequery.c  */
2957
2958 bool saf_store( const char *domain, const char *servername );
2959 bool saf_join_store( const char *domain, const char *servername );
2960 bool saf_delete( const char *domain );
2961 char *saf_fetch( const char *domain );
2962 NODE_STATUS_STRUCT *node_status_query(int fd,
2963                                         struct nmb_name *name,
2964                                         const struct sockaddr_storage *to_ss,
2965                                         int *num_names,
2966                                         struct node_status_extra *extra);
2967 bool name_status_find(const char *q_name,
2968                         int q_type,
2969                         int type,
2970                         const struct sockaddr_storage *to_ss,
2971                         fstring name);
2972 int ip_service_compare(struct ip_service *ss1, struct ip_service *ss2);
2973 struct sockaddr_storage *name_query(int fd,
2974                         const char *name,
2975                         int name_type,
2976                         bool bcast,
2977                         bool recurse,
2978                         const struct sockaddr_storage *to_ss,
2979                         int *count,
2980                         int *flags,
2981                         bool *timed_out);
2982 XFILE *startlmhosts(const char *fname);
2983 bool getlmhostsent(TALLOC_CTX *ctx, XFILE *fp, char **pp_name, int *name_type,
2984                 struct sockaddr_storage *pss);
2985 void endlmhosts(XFILE *fp);
2986 NTSTATUS name_resolve_bcast(const char *name,
2987                         int name_type,
2988                         struct ip_service **return_iplist,
2989                         int *return_count);
2990 NTSTATUS resolve_wins(const char *name,
2991                 int name_type,
2992                 struct ip_service **return_iplist,
2993                 int *return_count);
2994 NTSTATUS internal_resolve_name(const char *name,
2995                                 int name_type,
2996                                 const char *sitename,
2997                                 struct ip_service **return_iplist,
2998                                 int *return_count,
2999                                 const char *resolve_order);
3000 bool resolve_name(const char *name,
3001                 struct sockaddr_storage *return_ss,
3002                 int name_type);
3003 NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
3004                 const char *name,
3005                 int name_type,
3006                 struct sockaddr_storage **return_ss_arr,
3007                 unsigned int *p_num_entries);
3008 bool find_master_ip(const char *group, struct sockaddr_storage *master_ss);
3009 bool get_pdc_ip(const char *domain, struct sockaddr_storage *pss);
3010 NTSTATUS get_sorted_dc_list( const char *domain,
3011                         const char *sitename,
3012                         struct ip_service **ip_list,
3013                         int *count,
3014                         bool ads_only );
3015 NTSTATUS get_kdc_list( const char *realm,
3016                         const char *sitename,
3017                         struct ip_service **ip_list,
3018                         int *count);
3019
3020 /* The following definitions come from libsmb/namequery_dc.c  */
3021
3022 bool get_dc_name(const char *domain,
3023                 const char *realm,
3024                 fstring srv_name,
3025                 struct sockaddr_storage *ss_out);
3026
3027 /* The following definitions come from libsmb/nmblib.c  */
3028
3029 void debug_nmb_packet(struct packet_struct *p);
3030 void put_name(char *dest, const char *name, int pad, unsigned int name_type);
3031 char *nmb_namestr(const struct nmb_name *n);
3032 struct packet_struct *copy_packet(struct packet_struct *packet);
3033 void free_packet(struct packet_struct *packet);
3034 struct packet_struct *parse_packet(char *buf,int length,
3035                                    enum packet_type packet_type,
3036                                    struct in_addr ip,
3037                                    int port);
3038 struct packet_struct *read_packet(int fd,enum packet_type packet_type);
3039 void make_nmb_name( struct nmb_name *n, const char *name, int type);
3040 bool nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
3041 int build_packet(char *buf, size_t buflen, struct packet_struct *p);
3042 bool send_packet(struct packet_struct *p);
3043 struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
3044 struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id);
3045 struct packet_struct *receive_dgram_packet(int fd, int t,
3046                 const char *mailslot_name);
3047 bool match_mailslot_name(struct packet_struct *p, const char *mailslot_name);
3048 int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len);
3049 void sort_query_replies(char *data, int n, struct in_addr ip);
3050 char *name_mangle(TALLOC_CTX *mem_ctx, char *In, char name_type);
3051 int name_extract(char *buf,int ofs, fstring name);
3052 int name_len(char *s1);
3053
3054 /* The following definitions come from libsmb/nterr.c  */
3055
3056 const char *nt_errstr(NTSTATUS nt_code);
3057 const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
3058 const char *get_nt_error_c_code(NTSTATUS nt_code);
3059 NTSTATUS nt_status_string_to_code(const char *nt_status_str);
3060 NTSTATUS nt_status_squash(NTSTATUS nt_status);
3061
3062 /* The following definitions come from libsmb/ntlmssp.c  */
3063
3064 void debug_ntlmssp_flags(uint32 neg_flags);
3065 NTSTATUS ntlmssp_set_username(NTLMSSP_STATE *ntlmssp_state, const char *user) ;
3066 NTSTATUS ntlmssp_set_hashes(NTLMSSP_STATE *ntlmssp_state,
3067                 const unsigned char lm_hash[16],
3068                 const unsigned char nt_hash[16]) ;
3069 NTSTATUS ntlmssp_set_password(NTLMSSP_STATE *ntlmssp_state, const char *password) ;
3070 NTSTATUS ntlmssp_set_domain(NTLMSSP_STATE *ntlmssp_state, const char *domain) ;
3071 NTSTATUS ntlmssp_set_workstation(NTLMSSP_STATE *ntlmssp_state, const char *workstation) ;
3072 NTSTATUS ntlmssp_store_response(NTLMSSP_STATE *ntlmssp_state,
3073                                 DATA_BLOB response) ;
3074 void ntlmssp_want_feature_list(NTLMSSP_STATE *ntlmssp_state, char *feature_list);
3075 void ntlmssp_want_feature(NTLMSSP_STATE *ntlmssp_state, uint32 feature);
3076 NTSTATUS ntlmssp_update(NTLMSSP_STATE *ntlmssp_state, 
3077                         const DATA_BLOB in, DATA_BLOB *out) ;
3078 void ntlmssp_end(NTLMSSP_STATE **ntlmssp_state);
3079 DATA_BLOB ntlmssp_weaken_keys(NTLMSSP_STATE *ntlmssp_state, TALLOC_CTX *mem_ctx);
3080 NTSTATUS ntlmssp_server_start(NTLMSSP_STATE **ntlmssp_state);
3081 NTSTATUS ntlmssp_client_start(NTLMSSP_STATE **ntlmssp_state);
3082
3083 /* The following definitions come from libsmb/ntlmssp_sign.c  */
3084
3085 NTSTATUS ntlmssp_sign_packet(NTLMSSP_STATE *ntlmssp_state,
3086                                     const uchar *data, size_t length, 
3087                                     const uchar *whole_pdu, size_t pdu_length, 
3088                                     DATA_BLOB *sig) ;
3089 NTSTATUS ntlmssp_check_packet(NTLMSSP_STATE *ntlmssp_state,
3090                                 const uchar *data, size_t length, 
3091                                 const uchar *whole_pdu, size_t pdu_length, 
3092                                 const DATA_BLOB *sig) ;
3093 NTSTATUS ntlmssp_seal_packet(NTLMSSP_STATE *ntlmssp_state,
3094                              uchar *data, size_t length,
3095                              uchar *whole_pdu, size_t pdu_length,
3096                              DATA_BLOB *sig);
3097 NTSTATUS ntlmssp_unseal_packet(NTLMSSP_STATE *ntlmssp_state,
3098                                 uchar *data, size_t length,
3099                                 uchar *whole_pdu, size_t pdu_length,
3100                                 DATA_BLOB *sig);
3101 NTSTATUS ntlmssp_sign_init(NTLMSSP_STATE *ntlmssp_state);
3102
3103 /* The following definitions come from libsmb/passchange.c  */
3104
3105 NTSTATUS remote_password_change(const char *remote_machine, const char *user_name, 
3106                                 const char *old_passwd, const char *new_passwd,
3107                                 char **err_str);
3108
3109 /* The following definitions come from libsmb/samlogon_cache.c  */
3110
3111 bool netsamlogon_cache_init(void);
3112 bool netsamlogon_cache_shutdown(void);
3113 void netsamlogon_clear_cached_user(struct netr_SamInfo3 *info3);
3114 bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3);
3115 struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid);
3116 bool netsamlogon_cache_have(const DOM_SID *user_sid);
3117
3118 /* The following definitions come from libsmb/smb_seal.c  */
3119
3120 NTSTATUS get_enc_ctx_num(const uint8_t *buf, uint16 *p_enc_ctx_num);
3121 bool common_encryption_on(struct smb_trans_enc_state *es);
3122 NTSTATUS common_ntlm_decrypt_buffer(NTLMSSP_STATE *ntlmssp_state, char *buf);
3123 NTSTATUS common_ntlm_encrypt_buffer(NTLMSSP_STATE *ntlmssp_state,
3124                                 uint16 enc_ctx_num,
3125                                 char *buf,
3126                                 char **ppbuf_out);
3127 NTSTATUS common_encrypt_buffer(struct smb_trans_enc_state *es, char *buffer, char **buf_out);
3128 NTSTATUS common_decrypt_buffer(struct smb_trans_enc_state *es, char *buf);
3129 void common_free_encryption_state(struct smb_trans_enc_state **pp_es);
3130 void common_free_enc_buffer(struct smb_trans_enc_state *es, char *buf);
3131 bool cli_encryption_on(struct cli_state *cli);
3132 void cli_free_encryption_context(struct cli_state *cli);
3133 void cli_free_enc_buffer(struct cli_state *cli, char *buf);
3134 NTSTATUS cli_decrypt_message(struct cli_state *cli);
3135 NTSTATUS cli_encrypt_message(struct cli_state *cli, char *buf, char **buf_out);
3136
3137 /* The following definitions come from libsmb/clisigning.c  */
3138
3139 bool cli_simple_set_signing(struct cli_state *cli,
3140                             const DATA_BLOB user_session_key,
3141                             const DATA_BLOB response);
3142 bool cli_temp_set_signing(struct cli_state *cli);
3143 void cli_calculate_sign_mac(struct cli_state *cli, char *buf, uint32_t *seqnum);
3144 bool cli_check_sign_mac(struct cli_state *cli, const char *buf, uint32_t seqnum);
3145 bool client_is_signing_on(struct cli_state *cli);
3146 bool client_is_signing_allowed(struct cli_state *cli);
3147 bool client_is_signing_mandatory(struct cli_state *cli);
3148 void cli_set_signing_negotiated(struct cli_state *cli);
3149
3150 /* The following definitions come from smbd/signing.c  */
3151
3152 struct smbd_server_connection;
3153 bool srv_check_sign_mac(struct smbd_server_connection *conn,
3154                         const char *inbuf, uint32_t *seqnum);
3155 void srv_calculate_sign_mac(struct smbd_server_connection *conn,
3156                             char *outbuf, uint32_t seqnum);
3157 void srv_cancel_sign_response(struct smbd_server_connection *conn);
3158 bool srv_init_signing(struct smbd_server_connection *conn);
3159 void srv_set_signing_negotiated(struct smbd_server_connection *conn);
3160 bool srv_is_signing_active(struct smbd_server_connection *conn);
3161 bool srv_is_signing_negotiated(struct smbd_server_connection *conn);
3162 void srv_set_signing(struct smbd_server_connection *conn,
3163                      const DATA_BLOB user_session_key,
3164                      const DATA_BLOB response);
3165
3166 /* The following definitions come from libsmb/smberr.c  */
3167
3168 const char *smb_dos_err_name(uint8 e_class, uint16 num);
3169 const char *get_dos_error_msg(WERROR result);
3170 const char *smb_dos_err_class(uint8 e_class);
3171 char *smb_dos_errstr(char *inbuf);
3172 WERROR map_werror_from_unix(int error);
3173
3174 /* The following definitions come from libsmb/spnego.c  */
3175
3176 ssize_t read_spnego_data(DATA_BLOB data, SPNEGO_DATA *token);
3177 ssize_t write_spnego_data(DATA_BLOB *blob, SPNEGO_DATA *spnego);
3178 bool free_spnego_data(SPNEGO_DATA *spnego);
3179
3180 /* The following definitions come from libsmb/trustdom_cache.c  */
3181
3182 bool trustdom_cache_enable(void);
3183 bool trustdom_cache_shutdown(void);
3184 bool trustdom_cache_store(char* name, char* alt_name, const DOM_SID *sid,
3185                           time_t timeout);
3186 bool trustdom_cache_fetch(const char* name, DOM_SID* sid);
3187 uint32 trustdom_cache_fetch_timestamp( void );
3188 bool trustdom_cache_store_timestamp( uint32 t, time_t timeout );
3189 void trustdom_cache_flush(void);
3190 void update_trustdom_cache( void );
3191
3192 /* The following definitions come from libsmb/trusts_util.c  */
3193
3194 NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
3195                                       const char *domain,
3196                                       unsigned char orig_trust_passwd_hash[16],
3197                                       uint32 sec_channel_type);
3198 NTSTATUS trust_pw_find_change_and_store_it(struct rpc_pipe_client *cli, 
3199                                            TALLOC_CTX *mem_ctx, 
3200                                            const char *domain) ;
3201 bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
3202                                      char ***domain_names, uint32 *num_domains,
3203                                      DOM_SID **sids );
3204
3205 /* The following definitions come from libsmb/unexpected.c  */
3206
3207 void unexpected_packet(struct packet_struct *p);
3208 void clear_unexpected(time_t t);
3209 struct packet_struct *receive_unexpected(enum packet_type packet_type, int id,
3210                                          const char *mailslot_name);
3211
3212 /* The following definitions come from locking/brlock.c  */
3213
3214 bool brl_same_context(const struct lock_context *ctx1, 
3215                              const struct lock_context *ctx2);
3216 NTSTATUS brl_lock_failed(files_struct *fsp, const struct lock_struct *lock, bool blocking_lock);
3217 void brl_init(bool read_only);
3218 void brl_shutdown(void);
3219
3220 NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
3221                 struct lock_struct *plock,
3222                 bool blocking_lock);
3223
3224 NTSTATUS brl_lock(struct messaging_context *msg_ctx,
3225                 struct byte_range_lock *br_lck,
3226                 uint32 smbpid,
3227                 struct server_id pid,
3228                 br_off start,
3229                 br_off size, 
3230                 enum brl_type lock_type,
3231                 enum brl_flavour lock_flav,
3232                 bool blocking_lock,
3233                 uint32 *psmbpid,
3234                 struct blocking_lock_record *blr);
3235 bool brl_unlock(struct messaging_context *msg_ctx,
3236                 struct byte_range_lock *br_lck,
3237                 uint32 smbpid,
3238                 struct server_id pid,
3239                 br_off start,
3240                 br_off size,
3241                 enum brl_flavour lock_flav);
3242 bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
3243                                struct byte_range_lock *br_lck,
3244                                const struct lock_struct *plock);
3245 bool brl_locktest(struct byte_range_lock *br_lck,
3246                 uint32 smbpid,
3247                 struct server_id pid,
3248                 br_off start,
3249                 br_off size, 
3250                 enum brl_type lock_type,
3251                 enum brl_flavour lock_flav);
3252 NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
3253                 uint32 *psmbpid,
3254                 struct server_id pid,
3255                 br_off *pstart,
3256                 br_off *psize, 
3257                 enum brl_type *plock_type,
3258                 enum brl_flavour lock_flav);
3259 bool brl_lock_cancel(struct byte_range_lock *br_lck,
3260                 uint32 smbpid,
3261                 struct server_id pid,
3262                 br_off start,
3263                 br_off size,
3264                 enum brl_flavour lock_flav,
3265                 struct blocking_lock_record *blr);
3266 bool brl_lock_cancel_default(struct byte_range_lock *br_lck,
3267                 struct lock_struct *plock);
3268 void brl_close_fnum(struct messaging_context *msg_ctx,
3269                     struct byte_range_lock *br_lck);
3270 int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
3271                           enum brl_type lock_type,
3272                           enum brl_flavour lock_flav,
3273                           br_off start, br_off size,
3274                           void *private_data),
3275                void *private_data);
3276 struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
3277                                         files_struct *fsp);
3278 struct byte_range_lock *brl_get_locks_readonly(TALLOC_CTX *mem_ctx,
3279                                         files_struct *fsp);
3280 void brl_register_msgs(struct messaging_context *msg_ctx);
3281
3282 /* The following definitions come from locking/locking.c  */
3283
3284 const char *lock_type_name(enum brl_type lock_type);
3285 const char *lock_flav_name(enum brl_flavour lock_flav);
3286 void init_strict_lock_struct(files_struct *fsp,
3287                                 uint32 smbpid,
3288                                 br_off start,
3289                                 br_off size,
3290                                 enum brl_type lock_type,
3291                                 struct lock_struct *plock);
3292 bool strict_lock_default(files_struct *fsp,
3293                                 struct lock_struct *plock);
3294 void strict_unlock_default(files_struct *fsp,
3295                                 struct lock_struct *plock);
3296 NTSTATUS query_lock(files_struct *fsp,
3297                         uint32 *psmbpid,
3298                         uint64_t *pcount,
3299                         uint64_t *poffset,
3300                         enum brl_type *plock_type,
3301                         enum brl_flavour lock_flav);
3302 struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
3303                         files_struct *fsp,
3304                         uint32 lock_pid,
3305                         uint64_t count,
3306                         uint64_t offset,
3307                         enum brl_type lock_type,
3308                         enum brl_flavour lock_flav,
3309                         bool blocking_lock,
3310                         NTSTATUS *perr,
3311                         uint32 *plock_pid,
3312                         struct blocking_lock_record *blr);
3313 NTSTATUS do_unlock(struct messaging_context *msg_ctx,
3314                         files_struct *fsp,
3315                         uint32 lock_pid,
3316                         uint64_t count,
3317                         uint64_t offset,
3318                         enum brl_flavour lock_flav);
3319 NTSTATUS do_lock_cancel(files_struct *fsp,
3320                         uint32 lock_pid,
3321                         uint64_t count,
3322                         uint64_t offset,
3323                         enum brl_flavour lock_flav,
3324                         struct blocking_lock_record *blr);
3325 void locking_close_file(struct messaging_context *msg_ctx,
3326                         files_struct *fsp);
3327 bool locking_init(void);
3328 bool locking_init_readonly(void);
3329 bool locking_end(void);
3330 char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
3331 struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
3332                                             const struct file_id id,
3333                                             const char *servicepath,
3334                                             const char *fname,
3335                                             const struct timespec *old_write_time);
3336 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
3337                                                   const struct file_id id,
3338                                                   const char *servicepath,
3339                                                   const char *fname);
3340 bool rename_share_filename(struct messaging_context *msg_ctx,
3341                         struct share_mode_lock *lck,
3342                         const char *servicepath,
3343                         const char *newname);
3344 void get_file_infos(struct file_id id,
3345                     bool *delete_on_close,
3346                     struct timespec *write_time);
3347 bool is_valid_share_mode_entry(const struct share_mode_entry *e);
3348 bool is_deferred_open_entry(const struct share_mode_entry *e);
3349 bool is_unused_share_mode_entry(const struct share_mode_entry *e);
3350 void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
3351                     uid_t uid, uint16 mid, uint16 op_type);
3352 void add_deferred_open(struct share_mode_lock *lck, uint16 mid,
3353                        struct timeval request_time,
3354                        struct file_id id);
3355 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
3356 void del_deferred_open_entry(struct share_mode_lock *lck, uint16 mid);
3357 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
3358 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
3359 NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close,
3360                                  uint32 dosmode);
3361 void set_delete_on_close_token(struct share_mode_lock *lck, const UNIX_USER_TOKEN *tok);
3362 void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, const UNIX_USER_TOKEN *tok);
3363 bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const UNIX_USER_TOKEN *tok);
3364 bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
3365 bool set_write_time(struct file_id fileid, struct timespec write_time);
3366 int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
3367                                  const char *, void *),
3368                       void *private_data);
3369
3370 /* The following definitions come from locking/posix.c  */
3371
3372 bool is_posix_locked(files_struct *fsp,
3373                         uint64_t *pu_offset,
3374                         uint64_t *pu_count,
3375                         enum brl_type *plock_type,
3376                         enum brl_flavour lock_flav);
3377 bool posix_locking_init(bool read_only);
3378 bool posix_locking_end(void);
3379 void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount);
3380 int fd_close_posix(struct files_struct *fsp);
3381 bool set_posix_lock_windows_flavour(files_struct *fsp,
3382                         uint64_t u_offset,
3383                         uint64_t u_count,
3384                         enum brl_type lock_type,
3385                         const struct lock_context *lock_ctx,
3386                         const struct lock_struct *plocks,
3387                         int num_locks,
3388                         int *errno_ret);
3389 bool release_posix_lock_windows_flavour(files_struct *fsp,
3390                                 uint64_t u_offset,
3391                                 uint64_t u_count,
3392                                 enum brl_type deleted_lock_type,
3393                                 const struct lock_context *lock_ctx,
3394                                 const struct lock_struct *plocks,
3395                                 int num_locks);
3396 bool set_posix_lock_posix_flavour(files_struct *fsp,
3397                         uint64_t u_offset,
3398                         uint64_t u_count,
3399                         enum brl_type lock_type,
3400                         int *errno_ret);
3401 bool release_posix_lock_posix_flavour(files_struct *fsp,
3402                                 uint64_t u_offset,
3403                                 uint64_t u_count,
3404                                 const struct lock_context *lock_ctx,
3405                                 const struct lock_struct *plocks,
3406                                 int num_locks);
3407
3408 /* The following definitions come from modules/vfs_default.c  */
3409
3410 int vfswrap_lstat(vfs_handle_struct *handle,  const char *path, SMB_STRUCT_STAT *sbuf);
3411 ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size);
3412 ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size);
3413 NTSTATUS vfs_default_init(void);
3414
3415 /* The following definitions come from nmbd/asyncdns.c  */
3416
3417 int asyncdns_fd(void);
3418 void kill_async_dns_child(void);
3419 void start_async_dns(void);
3420 void run_dns_queue(void);
3421 bool queue_dns_query(struct packet_struct *p,struct nmb_name *question);
3422 bool queue_dns_query(struct packet_struct *p,struct nmb_name *question);
3423 void kill_async_dns_child(void);
3424
3425 /* The following definitions come from nmbd/nmbd.c  */
3426
3427 struct event_context *nmbd_event_context(void);
3428 struct messaging_context *nmbd_messaging_context(void);
3429
3430 /* The following definitions come from nmbd/nmbd_become_dmb.c  */
3431
3432 void add_domain_names(time_t t);
3433
3434 /* The following definitions come from nmbd/nmbd_become_lmb.c  */
3435
3436 void insert_permanent_name_into_unicast( struct subnet_record *subrec, 
3437                                                 struct nmb_name *nmbname, uint16 nb_type );
3438 void unbecome_local_master_browser(struct subnet_record *subrec, struct work_record *work,
3439                                    bool force_new_election);
3440 void become_local_master_browser(struct subnet_record *subrec, struct work_record *work);
3441 void set_workgroup_local_master_browser_name( struct work_record *work, const char *newname);
3442
3443 /* The following definitions come from nmbd/nmbd_browserdb.c  */
3444
3445 void update_browser_death_time( struct browse_cache_record *browc );
3446 struct browse_cache_record *create_browser_in_lmb_cache( const char *work_name, 
3447                                                          const char *browser_name, 
3448                                                          struct in_addr ip );
3449 struct browse_cache_record *find_browser_in_lmb_cache( const char *browser_name );
3450 void expire_lmb_browsers( time_t t );
3451
3452 /* The following definitions come from nmbd/nmbd_browsesync.c  */
3453
3454 void dmb_expire_and_sync_browser_lists(time_t t);
3455 void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec,
3456                                                    struct work_record *work);
3457 void collect_all_workgroup_names_from_wins_server(time_t t);
3458 void sync_all_dmbs(time_t t);
3459
3460 /* The following definitions come from nmbd/nmbd_elections.c  */
3461
3462 void check_master_browser_exists(time_t t);
3463 void run_elections(time_t t);
3464 void process_election(struct subnet_record *subrec, struct packet_struct *p, char *buf);
3465 bool check_elections(void);
3466 void nmbd_message_election(struct messaging_context *msg,
3467                            void *private_data,
3468                            uint32_t msg_type,
3469                            struct server_id server_id,
3470                            DATA_BLOB *data);
3471
3472 /* The following definitions come from nmbd/nmbd_incomingdgrams.c  */
3473
3474 void tell_become_backup(void);
3475 void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
3476 void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
3477 void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
3478 void process_master_browser_announce(struct subnet_record *subrec, 
3479                                      struct packet_struct *p,char *buf);
3480 void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len);
3481 void process_get_backup_list_request(struct subnet_record *subrec,
3482                                      struct packet_struct *p,char *buf);
3483 void process_reset_browser(struct subnet_record *subrec,
3484                                   struct packet_struct *p,char *buf);
3485 void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf);
3486 void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len);
3487
3488 /* The following definitions come from nmbd/nmbd_incomingrequests.c  */
3489
3490 void process_name_release_request(struct subnet_record *subrec, 
3491                                   struct packet_struct *p);
3492 void process_name_refresh_request(struct subnet_record *subrec,
3493                                   struct packet_struct *p);
3494 void process_name_registration_request(struct subnet_record *subrec, 
3495                                        struct packet_struct *p);
3496 void process_node_status_request(struct subnet_record *subrec, struct packet_struct *p);
3497 void process_name_query_request(struct subnet_record *subrec, struct packet_struct *p);
3498
3499 /* The following definitions come from nmbd/nmbd_lmhosts.c  */
3500
3501 void load_lmhosts_file(const char *fname);
3502 bool find_name_in_lmhosts(struct nmb_name *nmbname, struct name_record **namerecp);
3503
3504 /* The following definitions come from nmbd/nmbd_logonnames.c  */
3505
3506 void add_logon_names(void);
3507
3508 /* The following definitions come from nmbd/nmbd_mynames.c  */
3509
3510 void register_my_workgroup_one_subnet(struct subnet_record *subrec);
3511 bool register_my_workgroup_and_names(void);
3512 void release_wins_names(void);
3513 void refresh_my_names(time_t t);
3514
3515 /* The following definitions come from nmbd/nmbd_namelistdb.c  */
3516
3517 void set_samba_nb_type(void);
3518 void remove_name_from_namelist(struct subnet_record *subrec, 
3519                                 struct name_record *namerec );
3520 struct name_record *find_name_on_subnet(struct subnet_record *subrec,
3521                                 const struct nmb_name *nmbname,
3522                                 bool self_only);
3523 struct name_record *find_name_for_remote_broadcast_subnet(struct nmb_name *nmbname,
3524                                                 bool self_only);
3525 void update_name_ttl( struct name_record *namerec, int ttl );
3526 bool add_name_to_subnet( struct subnet_record *subrec,
3527                         const char *name,
3528                         int type,
3529                         uint16 nb_flags,
3530                         int ttl,
3531                         enum name_source source,
3532                         int num_ips,
3533                         struct in_addr *iplist);
3534 void standard_success_register(struct subnet_record *subrec, 
3535                              struct userdata_struct *userdata,
3536                              struct nmb_name *nmbname, uint16 nb_flags, int ttl,
3537                              struct in_addr registered_ip);
3538 void standard_fail_register( struct subnet_record   *subrec,
3539                              struct nmb_name        *nmbname );
3540 bool find_ip_in_name_record( struct name_record *namerec, struct in_addr ip );
3541 void add_ip_to_name_record( struct name_record *namerec, struct in_addr new_ip );
3542 void remove_ip_f