1e6209940SPedro F. Giffuni /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 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 /* 29e7ff5475SWarner Losh * Options 30e7ff5475SWarner Losh */ 31e7ff5475SWarner Losh 32e7ff5475SWarner Losh void init_options(void); 33e7ff5475SWarner Losh uint16_t make_options(int peer, char *buffer, uint16_t size); 34e7ff5475SWarner Losh int parse_options(int peer, char *buffer, uint16_t size); 35e7ff5475SWarner Losh 36e7ff5475SWarner Losh /* Call back functions */ 37e7ff5475SWarner Losh int option_tsize(int peer, struct tftphdr *, int, struct stat *); 38e7ff5475SWarner Losh int option_timeout(int peer); 39e7ff5475SWarner Losh int option_blksize(int peer); 40e7ff5475SWarner Losh int option_blksize2(int peer); 41e7ff5475SWarner Losh int option_rollover(int peer); 42fdf929ffSJohn Baldwin int option_windowsize(int peer); 43e7ff5475SWarner Losh 44e7ff5475SWarner Losh extern int options_extra_enabled; 45e7ff5475SWarner Losh extern int options_rfc_enabled; 46e7ff5475SWarner Losh 47e7ff5475SWarner Losh struct options { 48e7ff5475SWarner Losh const char *o_type; 49e7ff5475SWarner Losh char *o_request; 50e7ff5475SWarner Losh char *o_reply; 51e7ff5475SWarner Losh int (*o_handler)(int peer); 52e7ff5475SWarner Losh int rfc; 53e7ff5475SWarner Losh }; 54e7ff5475SWarner Losh 55e7ff5475SWarner Losh extern struct options options[]; 56e7ff5475SWarner Losh enum opt_enum { 57e7ff5475SWarner Losh OPT_TSIZE = 0, 58e7ff5475SWarner Losh OPT_TIMEOUT, 59e7ff5475SWarner Losh OPT_BLKSIZE, 60e7ff5475SWarner Losh OPT_BLKSIZE2, 61e7ff5475SWarner Losh OPT_ROLLOVER, 62fdf929ffSJohn Baldwin OPT_WINDOWSIZE, 63e7ff5475SWarner Losh }; 64b15e052eSDag-Erling Smørgrav 65b15e052eSDag-Erling Smørgrav int options_set_request(enum opt_enum, const char *, ...) 668576f84bSJohn Baldwin __printf0like(2, 3); 67b15e052eSDag-Erling Smørgrav int options_set_reply(enum opt_enum, const char *, ...) 688576f84bSJohn Baldwin __printf0like(2, 3); 69