1180948Skmacy/*-
2180948Skmacy * Copyright (c) 1982, 1986, 1990, 1993
3180948Skmacy *	The Regents of the University of California.  All rights reserved.
4180948Skmacy *
5180948Skmacy * Redistribution and use in source and binary forms, with or without
6180948Skmacy * modification, are permitted provided that the following conditions
7180948Skmacy * are met:
8180948Skmacy * 1. Redistributions of source code must retain the above copyright
9180948Skmacy *    notice, this list of conditions and the following disclaimer.
10180948Skmacy * 2. Redistributions in binary form must reproduce the above copyright
11180948Skmacy *    notice, this list of conditions and the following disclaimer in the
12180948Skmacy *    documentation and/or other materials provided with the distribution.
13180948Skmacy * 4. Neither the name of the University nor the names of its contributors
14180948Skmacy *    may be used to endorse or promote products derived from this software
15180948Skmacy *    without specific prior written permission.
16180948Skmacy *
17180948Skmacy * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18180948Skmacy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19180948Skmacy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20180948Skmacy * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21180948Skmacy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22180948Skmacy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23180948Skmacy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24180948Skmacy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25180948Skmacy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26180948Skmacy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27180948Skmacy * SUCH DAMAGE.
28180948Skmacy *
29180948Skmacy *	@(#)socketvar.h	8.3 (Berkeley) 2/19/95
30180948Skmacy *
31180948Skmacy * $FreeBSD$
32180948Skmacy */
33180948Skmacy#ifndef _SYS_SOCKOPT_H_
34180948Skmacy#define _SYS_SOCKOPT_H_
35180948Skmacy
36180948Skmacy#ifndef _KERNEL
37180948Skmacy#error "no user-servicable parts inside"
38180948Skmacy#endif
39180948Skmacy
40180948Skmacy
41180948Skmacystruct thread;
42180948Skmacystruct socket;
43180948Skmacy
44180948Skmacy/*
45180948Skmacy * Argument structure for sosetopt et seq.  This is in the KERNEL
46180948Skmacy * section because it will never be visible to user code.
47180948Skmacy */
48180948Skmacyenum sopt_dir { SOPT_GET, SOPT_SET };
49180948Skmacy
50180948Skmacystruct	sockopt {
51180948Skmacy	enum	sopt_dir sopt_dir; /* is this a get or a set? */
52180948Skmacy	int	sopt_level;	/* second arg of [gs]etsockopt */
53180948Skmacy	int	sopt_name;	/* third arg of [gs]etsockopt */
54180948Skmacy	void   *sopt_val;	/* fourth arg of [gs]etsockopt */
55180948Skmacy	size_t	sopt_valsize;	/* (almost) fifth arg of [gs]etsockopt */
56180948Skmacy	struct	thread *sopt_td; /* calling thread or null if kernel */
57180948Skmacy};
58180948Skmacy
59180948Skmacyint	sosetopt(struct socket *so, struct sockopt *sopt);
60180948Skmacyint	sogetopt(struct socket *so, struct sockopt *sopt);
61180948Skmacyint	sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);
62180948Skmacyint	sooptcopyout(struct sockopt *sopt, const void *buf, size_t len);
63180948Skmacy/* XXX; prepare mbuf for (__FreeBSD__ < 3) routines. */
64180948Skmacyint	soopt_getm(struct sockopt *sopt, struct mbuf **mp);
65180948Skmacyint	soopt_mcopyin(struct sockopt *sopt, struct mbuf *m);
66180948Skmacyint	soopt_mcopyout(struct sockopt *sopt, struct mbuf *m);
67180948Skmacyint	do_getopt_accept_filter(struct socket *so, struct sockopt *sopt);
68180948Skmacyint	do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
69180948Skmacyint	so_setsockopt(struct socket *so, int level, int optname,
70180948Skmacy	    void *optval, size_t optlen);
71180948Skmacy
72180948Skmacy#endif /* _SYS_SOCKOPT_H_ */
73