xref: /openbsd/usr.sbin/npppd/npppd/npppd_iface.h (revision 963e0d12)
1 /*	$OpenBSD: npppd_iface.h,v 1.8 2024/02/26 08:29:37 yasuoka Exp $ */
2 
3 /*-
4  * Copyright (c) 2009 Internet Initiative Japan Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 #ifndef NPPPD_IFACE_H
29 #define NPPPD_IFACE_H 1
30 
31 typedef struct _npppd_iface {
32 	/** base of npppd structure */
33 	void	*npppd;
34 	/** interface name */
35 	char	ifname[IFNAMSIZ];
36 	/** file descriptor for device file */
37 	int	devf;
38 
39 	/** assigned IPv4 address */
40 	struct in_addr	ip4addr;
41 	/** for event(3)  */
42 	struct event	ev;
43 
44 	struct ipcpconf *ipcpconf;
45 
46 	unsigned int	/**
47 		 * whether set IP address as npppd_iface's work or not.
48 		 * <p>if 0, npppd_iface only refers IP address already set.</p>
49 		 */
50 		set_ip4addr:1,
51 		/** set if using pppx(4) rather than tun(4) */
52 		using_pppx:1,
53 		/** is initialized */
54 		initialized:1,
55 		/** is started */
56 		started:1;
57 } npppd_iface;
58 
59 /** whether interface IP address is usable or not */
60 #define npppd_iface_ip_is_ready(_iface)		\
61     ((_iface)->initialized != 0 && (_iface)->ip4addr.s_addr != INADDR_ANY)
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 void  npppd_iface_init (npppd *, npppd_iface *, struct iface *);
68 int   npppd_iface_reinit (npppd_iface *, struct iface *);
69 int   npppd_iface_start (npppd_iface *);
70 void  npppd_iface_stop (npppd_iface *);
71 void  npppd_iface_fini (npppd_iface *);
72 void  npppd_iface_write (npppd_iface *, npppd_ppp *, int proto, u_char *, int);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 #endif
78