summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/ipoe/ipoe.c
diff options
context:
space:
mode:
authorDmitriyEshenko <snooppy@mail.ua>2019-08-20 12:56:14 +0300
committerDmitriyEshenko <snooppy@mail.ua>2019-08-20 12:56:14 +0300
commit668150d2cdb2c25966a4bbd398db85e33c8488a2 (patch)
tree00c7fd7c8131373d847eea13faebf0cc181d3232 /accel-pppd/ctrl/ipoe/ipoe.c
parent7b62a4038bc2d9a48c86856ab7726da311007fee (diff)
downloadaccel-ppp-668150d2cdb2c25966a4bbd398db85e33c8488a2.tar.gz
accel-ppp-668150d2cdb2c25966a4bbd398db85e33c8488a2.zip
Prepared check-ip and for ipoe, migrate to [common]check-ip
Diffstat (limited to 'accel-pppd/ctrl/ipoe/ipoe.c')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 5438b613..9880162c 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -107,6 +107,7 @@ struct local_net {
enum {SID_MAC, SID_IP};
+static int conf_check_exists;
static int conf_dhcpv4 = 1;
static int conf_up;
static int conf_auto;
@@ -577,6 +578,24 @@ static int ipoe_create_interface(struct ipoe_session *ses)
return 0;
}
+static int check_exists(struct ipoe_session *self_ipoe, in_addr_t addr)
+{
+ struct ap_session *ses;
+ int r = 0;
+
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ if (!ses->terminating && ses->ipv4 && ses->ipv4->peer_addr == addr && ses != &self_ipoe->ses) {
+ log_ppp_warn("ipoe: IPv4 address already assigned to %s\n", ses->ifname);
+ r = 1;
+ break;
+ }
+ }
+ pthread_rwlock_unlock(&ses_lock);
+
+ return r;
+}
+
static void auth_result(struct ipoe_session *ses, int r)
{
char *username = ses->username;
@@ -617,6 +636,11 @@ static void auth_result(struct ipoe_session *ses, int r)
ap_session_set_username(&ses->ses, username);
log_ppp_info1("%s: authentication succeeded\n", ses->ses.username);
+ if (conf_check_exists && check_exists(ses, ses->yiaddr)){
+ ap_session_terminate(&ses->ses, TERM_NAS_REQUEST, 1);
+ return;
+ }
+
cont:
triton_event_fire(EV_SES_AUTHORIZED, &ses->ses);
@@ -3930,6 +3954,10 @@ static void load_config(void)
else
conf_weight = 0;
+ opt = conf_get_opt("common", "check-ip");
+ if (opt && atoi(opt) >= 0)
+ conf_check_exists = atoi(opt) > 0;
+
#ifdef RADIUS
if (triton_module_loaded("radius"))
load_radius_attrs();