1 /*- 2 * Copyright (c) 2009 Internet Initiative Japan Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 #ifndef NPPPD_H 27 #define NPPPD_H 1 28 29 #define NPPPD_USER "_npppd" 30 31 #ifndef NPPPD_DEFAULT_TUN_IFNAME 32 #define NPPPD_DEFAULT_TUN_IFNAME "tun0" 33 #endif 34 35 36 #define DEFAULT_RADIUS_AUTH_IPADDR "127.0.0.1" 37 #define DEFAULT_RADIUS_AUTH_PORT 1812 38 #define DEFAULT_RADIUS_AUTH_TIMEOUT 9 39 40 #define DEFAULT_AUTH_TIMEOUT 30 41 42 /** assign fixed IP address */ 43 #define NPPPD_IP_ASSIGN_FIXED 0x0001 44 45 /** accept IP address which is proposed by peer and assign it */ 46 #define NPPPD_IP_ASSIGN_USER_SELECT 0x0002 47 48 /** use RADIUS Framed-IP-Address */ 49 #define NPPPD_IP_ASSIGN_RADIUS 0x0004 50 51 /** sockaddr_npppd */ 52 struct sockaddr_npppd { 53 struct sockaddr_in sin4; 54 struct sockaddr_in sin4mask; 55 #define snp_len sin4.sin_len 56 #define snp_family sin4.sin_family 57 #define snp_addr sin4.sin_addr 58 int snp_type; /* SNP_POOL or SNP_PPP */ 59 #define snp_mask sin4mask.sin_addr 60 /** next entry */ 61 struct sockaddr_npppd *snp_next; 62 /** contents of entry */ 63 void *snp_data_ptr; 64 }; 65 #define SNP_POOL 1 66 #define SNP_DYN_POOL 2 67 #define SNP_PPP 3 68 69 typedef struct _npppd npppd; 70 71 #include "ppp.h" 72 73 #ifdef __cplusplus 74 extern "C" { 75 #endif 76 77 78 npppd *npppd_get_npppd (void); 79 int npppd_init (npppd *, const char *); 80 void npppd_stop (npppd *); 81 void npppd_fini (npppd *); 82 int npppd_prepare_ip (npppd *, npppd_ppp *); 83 void npppd_release_ip (npppd *, npppd_ppp *); 84 int nppp_load_user_setting(npppd *, npppd_ppp *); 85 void npppd_set_ip_enabled (npppd *, npppd_ppp *, int); 86 int npppd_get_user_password (npppd *, npppd_ppp *, const char *, char *, int *); 87 struct in_addr *npppd_get_user_framed_ip_address(npppd *, npppd_ppp *, const char *); 88 int npppd_check_calling_number (npppd *, npppd_ppp *); 89 void npppd_network_output (npppd *, npppd_ppp *, int, u_char *, int); 90 void npppd_network_input (npppd *, uint8_t *, int); 91 npppd_ppp *npppd_get_ppp_by_ip (npppd *, struct in_addr); 92 slist *npppd_get_ppp_by_user (npppd *, const char *); 93 int npppd_check_user_max_session(npppd *, npppd_ppp *); 94 int npppd_get_all_users (npppd *, slist *); 95 int npppd_set_radish (npppd *, void *); 96 int npppd_ppp_iface_is_ready(npppd *, npppd_ppp *); 97 int sockaddr_npppd_match(void *, void *); 98 npppd_ppp *npppd_get_ppp_by_id(npppd *, int); 99 100 const char *npppd_config_str (npppd *, const char *); 101 int npppd_config_int (npppd *, const char *, int); 102 int npppd_config_str_equal (npppd *, const char *, const char *, int); 103 int npppd_config_str_equali (npppd *, const char *, const char *, int); 104 int npppd_modules_reload (npppd *); 105 int npppd_ifaces_load_config(npppd *); 106 int npppd_reload_config (npppd *); 107 int npppd_assign_ip_addr (npppd *, npppd_ppp *, uint32_t); 108 void npppd_release_ip_addr (npppd *, npppd_ppp *); 109 110 int npppd_ppp_bind_realm(npppd *, npppd_ppp *, const char *, int); 111 int npppd_ppp_is_realm_local(npppd *, npppd_ppp *); 112 int npppd_ppp_is_realm_radius(npppd *, npppd_ppp *); 113 int npppd_ppp_is_realm_ready(npppd *, npppd_ppp *); 114 const char *npppd_ppp_get_realm_name(npppd *, npppd_ppp *); 115 int npppd_ppp_bind_iface(npppd *, npppd_ppp *); 116 void npppd_ppp_unbind_iface(npppd *, npppd_ppp *); 117 const char *npppd_ppp_get_iface_name(npppd *, npppd_ppp *); 118 void * npppd_get_radius_req_setting(npppd *, npppd_ppp *); 119 void npppd_radius_server_failure_notify(npppd *, npppd_ppp *, void *, const char *); 120 int npppd_ppp_pipex_enable(npppd *, npppd_ppp *); 121 int npppd_ppp_pipex_disable(npppd *, npppd_ppp *); 122 const char *npppd_ppp_get_username_for_auth(npppd *, npppd_ppp *, const char *, char *); 123 int npppd_reset_routing_table(npppd *, int); 124 #ifdef __cplusplus 125 } 126 #endif 127 #endif 128