xref: /openbsd/usr.sbin/npppd/npppd/npppd.h (revision 8daf7599)
1 /* $OpenBSD: npppd.h,v 1.6 2011/07/06 20:52:28 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_H
29 #define	NPPPD_H 1
30 
31 #define	NPPPD_USER			"_npppd"
32 
33 #ifndef	NPPPD_DEFAULT_TUN_IFNAME
34 #define	NPPPD_DEFAULT_TUN_IFNAME	"tun0"
35 #endif
36 
37 
38 #define	DEFAULT_RADIUS_AUTH_PORT	1812
39 #define	DEFAULT_RADIUS_ACCT_PORT	1813
40 #define	DEFAULT_RADIUS_TIMEOUT		9
41 #define	DEFAULT_RADIUS_MAX_TRIES	3
42 #define	DEFAULT_RADIUS_MAX_FAILOVERS	1
43 #define	DEFAULT_AUTH_TIMEOUT		30
44 
45 /** assign fixed IP address */
46 #define NPPPD_IP_ASSIGN_FIXED		0x0001
47 
48 /** accept IP address which is proposed by peer and assign it */
49 #define NPPPD_IP_ASSIGN_USER_SELECT	0x0002
50 
51 /** use RADIUS Framed-IP-Address */
52 #define NPPPD_IP_ASSIGN_RADIUS		0x0004
53 
54 /** sockaddr_npppd */
55 struct sockaddr_npppd {
56 	struct sockaddr_in sin4;
57 	struct sockaddr_in sin4mask;
58 #define			snp_len		sin4.sin_len
59 #define			snp_family	sin4.sin_family
60 #define			snp_addr	sin4.sin_addr
61 	int		snp_type;	/* SNP_POOL or SNP_PPP */
62 #define			snp_mask	sin4mask.sin_addr
63 	/** next entry */
64 	struct sockaddr_npppd *snp_next;
65 	/** contents of entry */
66 	void 		*snp_data_ptr;
67 };
68 #define	SNP_POOL		1
69 #define	SNP_DYN_POOL		2
70 #define	SNP_PPP			3
71 
72 typedef struct _npppd		npppd;
73 
74 #include "ppp.h"
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 
81 npppd      *npppd_get_npppd (void);
82 int        npppd_init (npppd *, const char *);
83 void       npppd_stop (npppd *);
84 void       npppd_fini (npppd *);
85 int        npppd_prepare_ip (npppd *, npppd_ppp *);
86 void       npppd_release_ip (npppd *, npppd_ppp *);
87 int        nppp_load_user_setting(npppd *, npppd_ppp *);
88 void       npppd_set_ip_enabled (npppd *, npppd_ppp *, int);
89 int        npppd_get_user_password (npppd *, npppd_ppp *, const char *, char *, int *);
90 struct in_addr *npppd_get_user_framed_ip_address(npppd *, npppd_ppp *, const char *);
91 int        npppd_check_calling_number (npppd *, npppd_ppp *);
92 void       npppd_network_output (npppd *, npppd_ppp *, int, u_char *, int);
93 void       npppd_network_input (npppd *, uint8_t *, int);
94 npppd_ppp  *npppd_get_ppp_by_ip (npppd *, struct in_addr);
95 slist      *npppd_get_ppp_by_user (npppd *, const char *);
96 int        npppd_check_user_max_session(npppd *, npppd_ppp *);
97 int        npppd_get_all_users (npppd *, slist *);
98 int        npppd_set_radish (npppd *, void *);
99 int        npppd_ppp_iface_is_ready(npppd *, npppd_ppp *);
100 int        sockaddr_npppd_match(void *, void *);
101 npppd_ppp  *npppd_get_ppp_by_id(npppd *, int);
102 
103 const char  *npppd_config_str (npppd *, const char *);
104 int         npppd_config_int (npppd *, const char *, int);
105 int         npppd_config_str_equal (npppd *, const char *, const char *, int);
106 int         npppd_config_str_equali (npppd *, const char *, const char *, int);
107 int         npppd_modules_reload (npppd *);
108 int         npppd_ifaces_load_config(npppd *);
109 int         npppd_reload_config (npppd *);
110 int         npppd_assign_ip_addr (npppd *, npppd_ppp *, uint32_t);
111 void            npppd_release_ip_addr (npppd *, npppd_ppp *);
112 
113 int        npppd_ppp_bind_realm(npppd *, npppd_ppp *, const char *, int);
114 int        npppd_ppp_is_realm_local(npppd *, npppd_ppp *);
115 int        npppd_ppp_is_realm_radius(npppd *, npppd_ppp *);
116 int        npppd_ppp_is_realm_ready(npppd *, npppd_ppp *);
117 const char *npppd_ppp_get_realm_name(npppd *, npppd_ppp *);
118 int        npppd_ppp_bind_iface(npppd *, npppd_ppp *);
119 void       npppd_ppp_unbind_iface(npppd *, npppd_ppp *);
120 const char *npppd_ppp_get_iface_name(npppd *, npppd_ppp *);
121 void *     npppd_get_radius_auth_setting(npppd *, npppd_ppp *);
122 void       npppd_radius_auth_server_failure_notify(npppd *, npppd_ppp *, void *, const char *);
123 int        npppd_ppp_pipex_enable(npppd *, npppd_ppp *);
124 int        npppd_ppp_pipex_disable(npppd *, npppd_ppp *);
125 const char *npppd_ppp_get_username_for_auth(npppd *, npppd_ppp *, const char *, char *);
126 int        npppd_reset_routing_table(npppd *, int);
127 #ifdef __cplusplus
128 }
129 #endif
130 #endif
131