xref: /freebsd/libexec/tftpd/tftp-options.h (revision 8576f84b)
1e6209940SPedro F. Giffuni /*-
2e6209940SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3e6209940SPedro F. Giffuni  *
4e7ff5475SWarner Losh  * Copyright (C) 2008 Edwin Groothuis. All rights reserved.
5e7ff5475SWarner Losh  *
6e7ff5475SWarner Losh  * Redistribution and use in source and binary forms, with or without
7e7ff5475SWarner Losh  * modification, are permitted provided that the following conditions
8e7ff5475SWarner Losh  * are met:
9e7ff5475SWarner Losh  * 1. Redistributions of source code must retain the above copyright
10e7ff5475SWarner Losh  *    notice, this list of conditions and the following disclaimer.
11e7ff5475SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
12e7ff5475SWarner Losh  *    notice, this list of conditions and the following disclaimer in the
13e7ff5475SWarner Losh  *    documentation and/or other materials provided with the distribution.
14e7ff5475SWarner Losh  *
15e7ff5475SWarner Losh  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16e7ff5475SWarner Losh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17e7ff5475SWarner Losh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18e7ff5475SWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19e7ff5475SWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20e7ff5475SWarner Losh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21e7ff5475SWarner Losh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22e7ff5475SWarner Losh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23e7ff5475SWarner Losh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24e7ff5475SWarner Losh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25e7ff5475SWarner Losh  * SUCH DAMAGE.
26e7ff5475SWarner Losh  */
27e7ff5475SWarner Losh 
28e7ff5475SWarner Losh #include <sys/cdefs.h>
29e7ff5475SWarner Losh __FBSDID("$FreeBSD$");
30e7ff5475SWarner Losh 
31e7ff5475SWarner Losh /*
32e7ff5475SWarner Losh  * Options
33e7ff5475SWarner Losh  */
34e7ff5475SWarner Losh 
35e7ff5475SWarner Losh void		init_options(void);
36e7ff5475SWarner Losh uint16_t	make_options(int peer, char *buffer, uint16_t size);
37e7ff5475SWarner Losh int		parse_options(int peer, char *buffer, uint16_t size);
38e7ff5475SWarner Losh 
39e7ff5475SWarner Losh /* Call back functions */
40e7ff5475SWarner Losh int	option_tsize(int peer, struct tftphdr *, int, struct stat *);
41e7ff5475SWarner Losh int	option_timeout(int peer);
42e7ff5475SWarner Losh int	option_blksize(int peer);
43e7ff5475SWarner Losh int	option_blksize2(int peer);
44e7ff5475SWarner Losh int	option_rollover(int peer);
45fdf929ffSJohn Baldwin int	option_windowsize(int peer);
46e7ff5475SWarner Losh 
47e7ff5475SWarner Losh extern int options_extra_enabled;
48e7ff5475SWarner Losh extern int options_rfc_enabled;
49e7ff5475SWarner Losh 
50e7ff5475SWarner Losh struct options {
51e7ff5475SWarner Losh 	const char	*o_type;
52e7ff5475SWarner Losh 	char		*o_request;
53e7ff5475SWarner Losh 	char		*o_reply;
54e7ff5475SWarner Losh 	int		(*o_handler)(int peer);
55e7ff5475SWarner Losh 	int		rfc;
56e7ff5475SWarner Losh };
57e7ff5475SWarner Losh 
58e7ff5475SWarner Losh extern struct options	options[];
59e7ff5475SWarner Losh enum opt_enum {
60e7ff5475SWarner Losh 	OPT_TSIZE = 0,
61e7ff5475SWarner Losh 	OPT_TIMEOUT,
62e7ff5475SWarner Losh 	OPT_BLKSIZE,
63e7ff5475SWarner Losh 	OPT_BLKSIZE2,
64e7ff5475SWarner Losh 	OPT_ROLLOVER,
65fdf929ffSJohn Baldwin 	OPT_WINDOWSIZE,
66e7ff5475SWarner Losh };
67b15e052eSDag-Erling Smørgrav 
68b15e052eSDag-Erling Smørgrav int	options_set_request(enum opt_enum, const char *, ...)
698576f84bSJohn Baldwin 	__printf0like(2, 3);
70b15e052eSDag-Erling Smørgrav int	options_set_reply(enum opt_enum, const char *, ...)
718576f84bSJohn Baldwin 	__printf0like(2, 3);
72