xref: /freebsd/libexec/tftpd/tftp-io.h (revision e6209940dee96d8deed5ee7c2b2663512dd55db9)
1*e6209940SPedro F. Giffuni /*-
2*e6209940SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*e6209940SPedro 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 #define RP_NONE		0
32e7ff5475SWarner Losh #define	RP_RECVFROM	-1
33e7ff5475SWarner Losh #define	RP_TOOSMALL	-2
34e7ff5475SWarner Losh #define RP_ERROR	-3
35e7ff5475SWarner Losh #define RP_WRONGSOURCE	-4
36e7ff5475SWarner Losh #define	RP_TIMEOUT	-5
37e7ff5475SWarner Losh #define	RP_TOOBIG	-6
38e7ff5475SWarner Losh 
39e7ff5475SWarner Losh const char *errtomsg(int);
40e7ff5475SWarner Losh void	send_error(int peer, int);
41e7ff5475SWarner Losh int	send_wrq(int peer, char *, char *);
42e7ff5475SWarner Losh int	send_rrq(int peer, char *, char *);
43e7ff5475SWarner Losh int	send_oack(int peer);
44e7ff5475SWarner Losh int	send_ack(int peer, unsigned short);
45e7ff5475SWarner Losh int	send_data(int peer, uint16_t, char *, int);
46e7ff5475SWarner Losh int	receive_packet(int peer, char *, int, struct sockaddr_storage *, int);
47e7ff5475SWarner Losh 
48e7ff5475SWarner Losh extern struct sockaddr_storage peer_sock;
49e7ff5475SWarner Losh extern struct sockaddr_storage me_sock;
50