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