CVE-2023-3961:s3:torture: Add test SMB2-INVALID-PIPENAME to show we allow bad pipenam...
[Samba.git] / source3 / nmbd / nmbd_proto.h
blob4cfb58980f87679d745a89f284eb1d7356416e79
1 /*
2 * Unix SMB/CIFS implementation.
3 * NBT netbios routines and daemon - version 2
5 * Copyright (C) Andrew Tridgell 1994-1998
6 * Copyright (C) Jeremy Allison 1994-2005
7 * Copyright (C) Luke Kenneth Casson Leighton 1994-1998
8 * Copyright (C) John H Terpstra 1995-1998
9 * Copyright (C) Christopher R. Hertel 1998
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
11 * Copyright (C) Jelmer Vernooij 2002,2003
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 /* The following definitions come from nmbd/asyncdns.c */
29 int asyncdns_fd(void);
30 void kill_async_dns_child(void);
31 void start_async_dns(struct messaging_context *msg);
32 void run_dns_queue(struct messaging_context *msg);
33 bool queue_dns_query(struct packet_struct *p,struct nmb_name *question);
34 bool queue_dns_query(struct packet_struct *p,struct nmb_name *question);
35 void kill_async_dns_child(void);
37 /* The following definitions come from nmbd/nmbd.c */
39 struct tevent_context *nmbd_event_context(void);
41 /* The following definitions come from nmbd/nmbd_become_dmb.c */
43 void add_domain_names(time_t t);
45 /* The following definitions come from nmbd/nmbd_become_lmb.c */
47 void insert_permanent_name_into_unicast( struct subnet_record *subrec,
48 struct nmb_name *nmbname, uint16_t nb_type );
49 void unbecome_local_master_browser(struct subnet_record *subrec, struct work_record *work,
50 bool force_new_election);
51 void become_local_master_browser(struct subnet_record *subrec, struct work_record *work);
52 void set_workgroup_local_master_browser_name( struct work_record *work, const char *newname);
54 /* The following definitions come from nmbd/nmbd_browserdb.c */
56 void update_browser_death_time( struct browse_cache_record *browc );
57 struct browse_cache_record *create_browser_in_lmb_cache( const char *work_name,
58 const char *browser_name,
59 struct in_addr ip );
60 struct browse_cache_record *find_browser_in_lmb_cache( const char *browser_name );
61 void expire_lmb_browsers( time_t t );
63 /* The following definitions come from nmbd/nmbd_browsesync.c */
65 void dmb_expire_and_sync_browser_lists(time_t t);
66 void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec,
67 struct work_record *work);
68 void collect_all_workgroup_names_from_wins_server(time_t t);
69 void sync_all_dmbs(time_t t);
71 /* The following definitions come from nmbd/nmbd_elections.c */
73 void check_master_browser_exists(time_t t);
74 void run_elections(time_t t);
75 void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
76 bool check_elections(void);
77 void nmbd_message_election(struct messaging_context *msg,
78 void *private_data,
79 uint32_t msg_type,
80 struct server_id server_id,
81 DATA_BLOB *data);
83 /* The following definitions come from nmbd/nmbd_incomingdgrams.c */
85 void tell_become_backup(void);
86 void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
87 void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
88 void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
89 void process_master_browser_announce(struct subnet_record *subrec,
90 struct packet_struct *p,const char *buf);
91 void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len);
92 void process_get_backup_list_request(struct subnet_record *subrec,
93 struct packet_struct *p,const char *buf);
94 void process_reset_browser(struct subnet_record *subrec,
95 struct packet_struct *p,const char *buf);
96 void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
97 void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len);
99 /* The following definitions come from nmbd/nmbd_incomingrequests.c */
101 void process_name_release_request(struct subnet_record *subrec,
102 struct packet_struct *p);
103 void process_name_refresh_request(struct subnet_record *subrec,
104 struct packet_struct *p);
105 void process_name_registration_request(struct subnet_record *subrec,
106 struct packet_struct *p);
107 void process_node_status_request(struct subnet_record *subrec, struct packet_struct *p);
108 void process_name_query_request(struct subnet_record *subrec, struct packet_struct *p);
110 /* The following definitions come from nmbd/nmbd_lmhosts.c */
112 void load_lmhosts_file(const char *fname);
113 bool find_name_in_lmhosts(struct nmb_name *nmbname, struct name_record **namerecp);
115 /* The following definitions come from nmbd/nmbd_logonnames.c */
117 void add_logon_names(void);
119 /* The following definitions come from nmbd/nmbd_mynames.c */
121 bool nmbd_init_my_netbios_names(void);
122 const char *my_netbios_names(int i);
123 void register_my_workgroup_one_subnet(struct subnet_record *subrec);
124 bool register_my_workgroup_and_names(void);
125 void release_wins_names(void);
126 void refresh_my_names(time_t t);
128 /* The following definitions come from nmbd/nmbd_namelistdb.c */
130 void set_samba_nb_type(void);
131 void remove_name_from_namelist(struct subnet_record *subrec,
132 struct name_record *namerec );
133 struct name_record *find_name_on_subnet(struct subnet_record *subrec,
134 const struct nmb_name *nmbname,
135 bool self_only);
136 struct name_record *find_name_for_remote_broadcast_subnet(struct nmb_name *nmbname,
137 bool self_only);
138 void update_name_ttl( struct name_record *namerec, int ttl );
139 bool add_name_to_subnet( struct subnet_record *subrec,
140 const char *name,
141 int type,
142 uint16_t nb_flags,
143 int ttl,
144 enum name_source source,
145 int num_ips,
146 struct in_addr *iplist);
147 void standard_success_register(struct subnet_record *subrec,
148 struct userdata_struct *userdata,
149 struct nmb_name *nmbname, uint16_t nb_flags, int ttl,
150 struct in_addr registered_ip);
151 void standard_fail_register( struct subnet_record *subrec,
152 struct nmb_name *nmbname );
153 bool find_ip_in_name_record( struct name_record *namerec, struct in_addr ip );
154 void add_ip_to_name_record( struct name_record *namerec, struct in_addr new_ip );
155 void remove_ip_from_name_record( struct name_record *namerec,
156 struct in_addr remove_ip );
157 void standard_success_release( struct subnet_record *subrec,
158 struct userdata_struct *userdata,
159 struct nmb_name *nmbname,
160 struct in_addr released_ip );
161 void expire_names(time_t t);
162 void add_samba_names_to_subnet( struct subnet_record *subrec );
163 void dump_name_record(struct name_record *namerec, FILE *fp);
164 void dump_all_namelists(void);
166 /* The following definitions come from nmbd/nmbd_namequery.c */
168 bool query_name(struct subnet_record *subrec, const char *name, int type,
169 query_name_success_function success_fn,
170 query_name_fail_function fail_fn,
171 struct userdata_struct *userdata);
172 bool query_name_from_wins_server(struct in_addr ip_to,
173 const char *name, int type,
174 query_name_success_function success_fn,
175 query_name_fail_function fail_fn,
176 struct userdata_struct *userdata);
178 /* The following definitions come from nmbd/nmbd_nameregister.c */
180 void register_name(struct subnet_record *subrec,
181 const char *name, int type, uint16_t nb_flags,
182 register_name_success_function success_fn,
183 register_name_fail_function fail_fn,
184 struct userdata_struct *userdata);
185 void wins_refresh_name(struct name_record *namerec);
187 /* The following definitions come from nmbd/nmbd_namerelease.c */
189 void release_name(struct subnet_record *subrec, struct name_record *namerec,
190 release_name_success_function success_fn,
191 release_name_fail_function fail_fn,
192 struct userdata_struct *userdata);
194 /* The following definitions come from nmbd/nmbd_nodestatus.c */
196 bool node_status(struct subnet_record *subrec, struct nmb_name *nmbname,
197 struct in_addr send_ip, node_status_success_function success_fn,
198 node_status_fail_function fail_fn, struct userdata_struct *userdata);
200 /* The following definitions come from nmbd/nmbd_packets.c */
202 bool nmbd_init_packet_server(void);
204 uint16_t get_nb_flags(char *buf);
205 void set_nb_flags(char *buf, uint16_t nb_flags);
206 struct response_record *queue_register_name( struct subnet_record *subrec,
207 response_function resp_fn,
208 timeout_response_function timeout_fn,
209 register_name_success_function success_fn,
210 register_name_fail_function fail_fn,
211 struct userdata_struct *userdata,
212 struct nmb_name *nmbname,
213 uint16_t nb_flags);
214 void queue_wins_refresh(struct nmb_name *nmbname,
215 response_function resp_fn,
216 timeout_response_function timeout_fn,
217 uint16_t nb_flags,
218 struct in_addr refresh_ip,
219 const char *tag);
220 struct response_record *queue_register_multihomed_name( struct subnet_record *subrec,
221 response_function resp_fn,
222 timeout_response_function timeout_fn,
223 register_name_success_function success_fn,
224 register_name_fail_function fail_fn,
225 struct userdata_struct *userdata,
226 struct nmb_name *nmbname,
227 uint16_t nb_flags,
228 struct in_addr register_ip,
229 struct in_addr wins_ip);
230 struct response_record *queue_release_name( struct subnet_record *subrec,
231 response_function resp_fn,
232 timeout_response_function timeout_fn,
233 release_name_success_function success_fn,
234 release_name_fail_function fail_fn,
235 struct userdata_struct *userdata,
236 struct nmb_name *nmbname,
237 uint16_t nb_flags,
238 struct in_addr release_ip,
239 struct in_addr dest_ip);
240 struct response_record *queue_query_name( struct subnet_record *subrec,
241 response_function resp_fn,
242 timeout_response_function timeout_fn,
243 query_name_success_function success_fn,
244 query_name_fail_function fail_fn,
245 struct userdata_struct *userdata,
246 struct nmb_name *nmbname);
247 struct response_record *queue_query_name_from_wins_server( struct in_addr to_ip,
248 response_function resp_fn,
249 timeout_response_function timeout_fn,
250 query_name_success_function success_fn,
251 query_name_fail_function fail_fn,
252 struct userdata_struct *userdata,
253 struct nmb_name *nmbname);
254 struct response_record *queue_node_status( struct subnet_record *subrec,
255 response_function resp_fn,
256 timeout_response_function timeout_fn,
257 node_status_success_function success_fn,
258 node_status_fail_function fail_fn,
259 struct userdata_struct *userdata,
260 struct nmb_name *nmbname,
261 struct in_addr send_ip);
262 void reply_netbios_packet(struct packet_struct *orig_packet,
263 int rcode, enum netbios_reply_type_code rcv_code, int opcode,
264 int ttl, char *data,int len);
265 void queue_packet(struct packet_struct *packet);
266 void run_packet_queue(void);
267 void retransmit_or_expire_response_records(time_t t);
268 bool listen_for_packets(struct messaging_context *msg, bool run_election);
269 bool send_mailslot(bool unique, const char *mailslot,char *buf, size_t len,
270 const char *srcname, int src_type,
271 const char *dstname, int dest_type,
272 struct in_addr dest_ip,struct in_addr src_ip,
273 int dest_port);
275 /* The following definitions come from nmbd/nmbd_processlogon.c */
277 bool initialize_nmbd_proxy_logon(void);
279 void process_logon_packet(struct packet_struct *p, const char *buf,int len,
280 const char *mailslot);
282 /* The following definitions come from nmbd/nmbd_responserecordsdb.c */
284 void remove_response_record(struct subnet_record *subrec,
285 struct response_record *rrec);
286 struct response_record *make_response_record( struct subnet_record *subrec,
287 struct packet_struct *p,
288 response_function resp_fn,
289 timeout_response_function timeout_fn,
290 success_function success_fn,
291 fail_function fail_fn,
292 struct userdata_struct *userdata);
293 struct response_record *find_response_record(struct subnet_record **ppsubrec,
294 uint16_t id);
295 bool is_refresh_already_queued(struct subnet_record *subrec, struct name_record *namerec);
297 /* The following definitions come from nmbd/nmbd_sendannounce.c */
299 void send_browser_reset(int reset_type, const char *to_name, int to_type, struct in_addr to_ip);
300 void broadcast_announce_request(struct subnet_record *subrec, struct work_record *work);
301 void announce_my_server_names(time_t t);
302 void announce_my_lm_server_names(time_t t);
303 void reset_announce_timer(void);
304 void announce_myself_to_domain_master_browser(time_t t);
305 void announce_my_servers_removed(void);
306 void announce_remote(time_t t);
307 void browse_sync_remote(time_t t);
309 /* The following definitions come from nmbd/nmbd_serverlistdb.c */
311 void remove_all_servers(struct work_record *work);
312 struct server_record *find_server_in_workgroup(struct work_record *work, const char *name);
313 void remove_server_from_workgroup(struct work_record *work, struct server_record *servrec);
314 struct server_record *create_server_on_workgroup(struct work_record *work,
315 const char *name,int servertype,
316 int ttl, const char *comment);
317 void update_server_ttl(struct server_record *servrec, int ttl);
318 void expire_servers(struct work_record *work, time_t t);
319 void write_browse_list_entry(FILE *fp, const char *name, uint32_t rec_type,
320 const char *local_master_browser_name, const char *description);
321 void write_browse_list(time_t t, bool force_write);
323 /* The following definitions come from nmbd/nmbd_subnetdb.c */
325 void close_subnet(struct subnet_record *subrec);
326 struct subnet_record *make_normal_subnet(const struct interface *iface);
327 bool create_subnets(void);
328 bool we_are_a_wins_client(void);
329 struct subnet_record *get_next_subnet_maybe_unicast(struct subnet_record *subrec);
330 struct subnet_record *get_next_subnet_maybe_unicast_or_wins_server(struct subnet_record *subrec);
332 /* The following definitions come from nmbd/nmbd_synclists.c */
334 void sync_browse_lists(struct work_record *work,
335 char *name, int nm_type,
336 struct in_addr ip, bool local, bool servers);
337 void sync_check_completion(void);
339 /* The following definitions come from nmbd/nmbd_winsproxy.c */
341 void make_wins_proxy_name_query_request( struct subnet_record *subrec,
342 struct packet_struct *incoming_packet,
343 struct nmb_name *question_name);
345 /* The following definitions come from nmbd/nmbd_winsserver.c */
347 struct name_record *find_name_on_wins_subnet(const struct nmb_name *nmbname, bool self_only);
348 bool wins_store_changed_namerec(const struct name_record *namerec);
349 bool add_name_to_wins_subnet(const struct name_record *namerec);
350 bool remove_name_from_wins_namelist(struct name_record *namerec);
351 void dump_wins_subnet_namelist(FILE *fp);
352 bool packet_is_for_wins_server(struct packet_struct *packet);
353 bool initialise_wins(void);
354 void wins_process_name_refresh_request( struct subnet_record *subrec,
355 struct packet_struct *p );
356 void wins_process_name_registration_request(struct subnet_record *subrec,
357 struct packet_struct *p);
358 void wins_process_multihomed_name_registration_request( struct subnet_record *subrec,
359 struct packet_struct *p);
360 void fetch_all_active_wins_1b_names(void);
361 void send_wins_name_query_response(int rcode, struct packet_struct *p,
362 struct name_record *namerec);
363 void wins_process_name_query_request(struct subnet_record *subrec,
364 struct packet_struct *p);
365 void wins_process_name_release_request(struct subnet_record *subrec,
366 struct packet_struct *p);
367 void initiate_wins_processing(time_t t);
368 void wins_write_name_record(struct name_record *namerec, FILE *fp);
369 void wins_write_database(time_t t, bool background);
370 void nmbd_wins_new_entry(struct messaging_context *msg,
371 void *private_data,
372 uint32_t msg_type,
373 struct server_id server_id,
374 DATA_BLOB *data);
376 /* The following definitions come from nmbd/nmbd_workgroupdb.c */
378 struct work_record *find_workgroup_on_subnet(struct subnet_record *subrec,
379 const char *name);
380 struct work_record *create_workgroup_on_subnet(struct subnet_record *subrec,
381 const char *name, int ttl);
382 void update_workgroup_ttl(struct work_record *work, int ttl);
383 void initiate_myworkgroup_startup(struct subnet_record *subrec, struct work_record *work);
384 void dump_workgroups(bool force_write);
385 void expire_workgroups_and_servers(time_t t);