summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-09-23 09:54:52 +0400
committerKozlov Dmitry <dima@server>2010-09-23 09:54:52 +0400
commit82b0f0953159fc9ab8e387f5e6014dc377b14b38 (patch)
tree974bf5ff111aed10829c4326d627c9e26d7f2189
parent3e61cb3f8d58f64c8023e95bf74341e6bc61560e (diff)
downloadaccel-ppp-82b0f0953159fc9ab8e387f5e6014dc377b14b38.tar.gz
accel-ppp-82b0f0953159fc9ab8e387f5e6014dc377b14b38.zip
radius: implemented attributes Calling-Station-Id, Called-Station-Id, NAS-IP-Address
radius: implemented extension Acct-Input-Gigawords, Acct-Output-Gigawords lcp: implemented maximum/minimum mtu/mru checks
-rw-r--r--accel-pptpd/accel-pptpd.conf4
-rw-r--r--accel-pptpd/ctrl/pptp.c19
-rw-r--r--accel-pptpd/ctrl/pptp_prot.h2
-rw-r--r--accel-pptpd/logs/CMakeLists.txt2
-rw-r--r--accel-pptpd/logs/log_file.c2
-rw-r--r--accel-pptpd/ppp/lcp_opt_mru.c73
-rw-r--r--accel-pptpd/ppp/ppp.h3
-rw-r--r--accel-pptpd/ppp/ppp_lcp.c13
-rw-r--r--accel-pptpd/radius/acct.c19
-rw-r--r--accel-pptpd/radius/packet.c7
-rw-r--r--accel-pptpd/radius/radius.c33
-rw-r--r--accel-pptpd/radius/radius.h1
-rw-r--r--accel-pptpd/radius/radius_p.h6
-rw-r--r--accel-pptpd/radius/req.c13
14 files changed, 146 insertions, 51 deletions
diff --git a/accel-pptpd/accel-pptpd.conf b/accel-pptpd/accel-pptpd.conf
index 965d9bcf..3aa9b188 100644
--- a/accel-pptpd/accel-pptpd.conf
+++ b/accel-pptpd/accel-pptpd.conf
@@ -15,6 +15,8 @@ thread-count=4
[ppp]
verbose=1
+min-mtu=1000
+mtu=1200
[lcp]
echo-interval=10
@@ -50,7 +52,7 @@ gw-ip-address=192.168.100.1
[log]
log-file=general.log
log-emerg=/dev/stderr
-log-debug=debug.log
+log-debug=/dev/stdout
copy=1
#color=1
per-user-dir=per_user
diff --git a/accel-pptpd/ctrl/pptp.c b/accel-pptpd/ctrl/pptp.c
index 9f76a341..d19420a9 100644
--- a/accel-pptpd/ctrl/pptp.c
+++ b/accel-pptpd/ctrl/pptp.c
@@ -18,7 +18,9 @@
#include "triton.h"
#include "log.h"
#include "ppp.h"
+#include "mempool.h"
#include "iprange.h"
+#include "utils.h"
#include "memdebug.h"
@@ -50,6 +52,8 @@ struct pptp_conn_t
static int conf_timeout = 3;
static int conf_echo_interval = 0;
+static mempool_t conn_pool;
+
static int pptp_read(struct triton_md_handler_t *h);
static int pptp_write(struct triton_md_handler_t *h);
static void pptp_timeout(struct triton_timer_t *);
@@ -81,7 +85,9 @@ static void disconnect(struct pptp_conn_t *conn)
_free(conn->in_buf);
_free(conn->out_buf);
- _free(conn);
+ _free(conn->ctrl.calling_station_id);
+ _free(conn->ctrl.called_station_id);
+ mempool_free(conn);
}
static int post_msg(struct pptp_conn_t *conn, void *buf, int size)
@@ -491,7 +497,7 @@ static int pptp_connect(struct triton_md_handler_t *h)
continue;
}
- conn = _malloc(sizeof(*conn));
+ conn = mempool_alloc(conn_pool);
memset(conn, 0, sizeof(*conn));
conn->hnd.fd = sock;
conn->hnd.read = pptp_read;
@@ -506,6 +512,13 @@ static int pptp_connect(struct triton_md_handler_t *h)
conn->ctrl.ctx = &conn->ctx;
conn->ctrl.started = ppp_started;
conn->ctrl.finished = ppp_finished;
+ conn->ctrl.max_mtu = PPTP_MAX_MTU;
+
+ conn->ctrl.calling_station_id = _malloc(17);
+ conn->ctrl.called_station_id = _malloc(17);
+ u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.calling_station_id);
+ getsockname(sock, &addr, &size);
+ u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.called_station_id);
ppp_init(&conn->ppp);
conn->ppp.ctrl = &conn->ctrl;
@@ -565,6 +578,8 @@ static void __init pptp_init(void)
return;
}
+ conn_pool = mempool_create(sizeof(struct pptp_conn_t));
+
triton_context_register(&serv.ctx, NULL);
triton_md_register_handler(&serv.ctx, &serv.hnd);
triton_md_enable_handler(&serv.hnd, MD_MODE_READ);
diff --git a/accel-pptpd/ctrl/pptp_prot.h b/accel-pptpd/ctrl/pptp_prot.h
index 7e3ebdd4..ee8cb341 100644
--- a/accel-pptpd/ctrl/pptp_prot.h
+++ b/accel-pptpd/ctrl/pptp_prot.h
@@ -3,6 +3,8 @@
#include <sys/types.h>
+#define PPTP_MAX_MTU 1436
+
#define hton8(x) (x)
#define ntoh8(x) (x)
#define hton16(x) htons(x)
diff --git a/accel-pptpd/logs/CMakeLists.txt b/accel-pptpd/logs/CMakeLists.txt
index 17ae92d0..4282761b 100644
--- a/accel-pptpd/logs/CMakeLists.txt
+++ b/accel-pptpd/logs/CMakeLists.txt
@@ -1,4 +1,4 @@
-ADD_LIBRARY(log_file SHARED log_file2.c)
+ADD_LIBRARY(log_file SHARED log_file.c)
ADD_LIBRARY(log_pgsql SHARED log_pgsql.c)
TARGET_LINK_LIBRARIES(log_pgsql pq)
diff --git a/accel-pptpd/logs/log_file.c b/accel-pptpd/logs/log_file.c
index b13f81a4..b39c6233 100644
--- a/accel-pptpd/logs/log_file.c
+++ b/accel-pptpd/logs/log_file.c
@@ -437,6 +437,8 @@ static void ev_ppp_starting(struct ppp_t *ppp)
if (rename(fname1, fname2))
log_emerg("log_file: rename '%s' to '%s': %s\n", fname1, fname2, strerror(errno));
+ lpd->tmp = 0;
+
_free(fname1);
_free(fname2);
}
diff --git a/accel-pptpd/ppp/lcp_opt_mru.c b/accel-pptpd/ppp/lcp_opt_mru.c
index 4dc96851..f13b0148 100644
--- a/accel-pptpd/ppp/lcp_opt_mru.c
+++ b/accel-pptpd/ppp/lcp_opt_mru.c
@@ -13,7 +13,8 @@
#include "memdebug.h"
-#define MAX_MTU 1436
+static int conf_mtu;
+static int conf_min_mtu = 100;
static struct lcp_option_t *mru_init(struct ppp_lcp_t *lcp);
static void mru_free(struct ppp_lcp_t *lcp, struct lcp_option_t *opt);
@@ -44,52 +45,52 @@ static struct lcp_option_handler_t mru_opt_hnd=
static struct lcp_option_t *mru_init(struct ppp_lcp_t *lcp)
{
struct mru_option_t *mru_opt=_malloc(sizeof(*mru_opt));
- memset(mru_opt,0,sizeof(*mru_opt));
- mru_opt->mtu=0;
- mru_opt->mru=MAX_MTU;
- mru_opt->opt.id=CI_MRU;
- mru_opt->opt.len=4;
+ memset(mru_opt, 0, sizeof(*mru_opt));
+ mru_opt->mtu = 0;
+ mru_opt->mru = (conf_mtu && conf_mtu <= lcp->ppp->ctrl->max_mtu) ? conf_mtu : lcp->ppp->ctrl->max_mtu;
+ mru_opt->opt.id = CI_MRU;
+ mru_opt->opt.len = 4;
return &mru_opt->opt;
}
static void mru_free(struct ppp_lcp_t *lcp, struct lcp_option_t *opt)
{
- struct mru_option_t *mru_opt=container_of(opt,typeof(*mru_opt),opt);
+ struct mru_option_t *mru_opt = container_of(opt, typeof(*mru_opt), opt);
_free(mru_opt);
}
static int mru_send_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr)
{
- struct mru_option_t *mru_opt=container_of(opt,typeof(*mru_opt),opt);
- struct lcp_opt16_t *opt16=(struct lcp_opt16_t*)ptr;
- opt16->hdr.id=CI_MRU;
- opt16->hdr.len=4;
- opt16->val=htons(mru_opt->mru);
+ struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt),opt);
+ struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
+ opt16->hdr.id = CI_MRU;
+ opt16->hdr.len = 4;
+ opt16->val = htons(mru_opt->mru);
return 4;
}
static int mru_send_conf_nak(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr)
{
- struct mru_option_t *mru_opt=container_of(opt,typeof(*mru_opt),opt);
- struct lcp_opt16_t *opt16=(struct lcp_opt16_t*)ptr;
- opt16->hdr.id=CI_MRU;
- opt16->hdr.len=4;
- opt16->val=htons(mru_opt->mtu);
+ struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt),opt);
+ struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
+ opt16->hdr.id = CI_MRU;
+ opt16->hdr.len = 4;
+ opt16->val = htons(mru_opt->mtu ? mru_opt->mtu : lcp->ppp->ctrl->max_mtu);
return 4;
}
static int mru_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr)
{
- struct mru_option_t *mru_opt=container_of(opt,typeof(*mru_opt),opt);
- struct lcp_opt16_t *opt16=(struct lcp_opt16_t*)ptr;
-
- if (!mru_opt->mtu || mru_opt->mtu==ntohs(opt16->val))
- {
- mru_opt->mtu=ntohs(opt16->val);
- return LCP_OPT_ACK;
- }else return LCP_OPT_NAK;
+ struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt),opt);
+ struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
+
+ if (ntohs(opt16->val) < conf_min_mtu || ntohs(opt16->val) > lcp->ppp->ctrl->max_mtu)
+ return LCP_OPT_NAK;
+
+ mru_opt->mtu = ntohs(opt16->val);
+ return LCP_OPT_ACK;
}
static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr)
@@ -110,17 +111,29 @@ static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
return 0;
}
-static void mru_print(void (*print)(const char *fmt,...),struct lcp_option_t *opt, uint8_t *ptr)
+static void mru_print(void (*print)(const char *fmt,...), struct lcp_option_t *opt, uint8_t *ptr)
{
- struct mru_option_t *mru_opt=container_of(opt,typeof(*mru_opt),opt);
- struct lcp_opt16_t *opt16=(struct lcp_opt16_t*)ptr;
+ struct mru_option_t *mru_opt = container_of(opt, typeof(*mru_opt), opt);
+ struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
- if (ptr) print("<mru %i>",ntohs(opt16->val));
- else print("<mru %i>",mru_opt->mru);
+ if (ptr)
+ print("<mru %i>",ntohs(opt16->val));
+ else
+ print("<mru %i>",mru_opt->mru);
}
static void __init mru_opt_init()
{
+ char *opt;
+
+ opt = conf_get_opt("ppp", "mtu");
+ if (opt && atoi(opt) > 0)
+ conf_mtu = atoi(opt);
+
+ opt = conf_get_opt("ppp", "min-mtu");
+ if (opt && atoi(opt) > 0)
+ conf_min_mtu = atoi(opt);
+
lcp_option_register(&mru_opt_hnd);
}
diff --git a/accel-pptpd/ppp/ppp.h b/accel-pptpd/ppp/ppp.h
index 641a74ba..5a8ac572 100644
--- a/accel-pptpd/ppp/ppp.h
+++ b/accel-pptpd/ppp/ppp.h
@@ -51,6 +51,9 @@ struct ppp_t;
struct ppp_ctrl_t
{
struct triton_context_t *ctx;
+ int max_mtu;
+ char *calling_station_id;
+ char *called_station_id;
void (*started)(struct ppp_t*);
void (*finished)(struct ppp_t*);
};
diff --git a/accel-pptpd/ppp/ppp_lcp.c b/accel-pptpd/ppp/ppp_lcp.c
index a85b3d12..d28167e2 100644
--- a/accel-pptpd/ppp/ppp_lcp.c
+++ b/accel-pptpd/ppp/ppp_lcp.c
@@ -29,6 +29,7 @@ static LIST_HEAD(option_handlers);
static void lcp_layer_up(struct ppp_fsm_t*);
static void lcp_layer_down(struct ppp_fsm_t*);
+static void lcp_layer_finished(struct ppp_fsm_t*);
static int send_conf_req(struct ppp_fsm_t*);
static void send_conf_ack(struct ppp_fsm_t*);
static void send_conf_nak(struct ppp_fsm_t*);
@@ -88,7 +89,8 @@ static struct ppp_layer_data_t *lcp_layer_init(struct ppp_t *ppp)
ppp_fsm_init(&lcp->fsm);
lcp->fsm.layer_up=lcp_layer_up;
- lcp->fsm.layer_finished=lcp_layer_down;
+ lcp->fsm.layer_down=lcp_layer_down;
+ lcp->fsm.layer_finished=lcp_layer_finished;
lcp->fsm.send_conf_req=send_conf_req;
lcp->fsm.send_conf_ack=send_conf_ack;
lcp->fsm.send_conf_nak=send_conf_nak;
@@ -150,7 +152,14 @@ static void lcp_layer_up(struct ppp_fsm_t *fsm)
static void lcp_layer_down(struct ppp_fsm_t *fsm)
{
struct ppp_lcp_t *lcp=container_of(fsm,typeof(*lcp),fsm);
- ppp_fsm_close(&lcp->fsm);
+ //ppp_fsm_close(&lcp->fsm);
+ stop_echo(lcp);
+ //ppp_layer_finished(lcp->ppp,&lcp->ld);
+}
+
+static void lcp_layer_finished(struct ppp_fsm_t *fsm)
+{
+ struct ppp_lcp_t *lcp=container_of(fsm,typeof(*lcp),fsm);
log_ppp_debug("lcp_layer_finished\n");
stop_echo(lcp);
ppp_layer_finished(lcp->ppp,&lcp->ld);
diff --git a/accel-pptpd/radius/acct.c b/accel-pptpd/radius/acct.c
index 6004138d..fb5e2e21 100644
--- a/accel-pptpd/radius/acct.c
+++ b/accel-pptpd/radius/acct.c
@@ -12,6 +12,8 @@
#include "memdebug.h"
+#define STAT_UPDATE_INTERVAL (10 * 60 * 1000)
+
static int req_set_RA(struct rad_req_t *req, const char *secret)
{
MD5_CTX ctx;
@@ -40,10 +42,20 @@ static void req_set_stat(struct rad_req_t *req, struct ppp_t *ppp)
return;
}
+ if (ifreq.stats.p.ppp_ibytes < req->rpd->acct_input_octets)
+ req->rpd->acct_input_gigawords++;
+ req->rpd->acct_input_octets = ifreq.stats.p.ppp_ibytes;
+
+ if (ifreq.stats.p.ppp_obytes < req->rpd->acct_output_octets)
+ req->rpd->acct_output_gigawords++;
+ req->rpd->acct_output_octets = ifreq.stats.p.ppp_obytes;
+
rad_packet_change_int(req->pack, "Acct-Input-Octets", ifreq.stats.p.ppp_ibytes);
rad_packet_change_int(req->pack, "Acct-Output-Octets", ifreq.stats.p.ppp_obytes);
rad_packet_change_int(req->pack, "Acct-Input-Packets", ifreq.stats.p.ppp_ipackets);
rad_packet_change_int(req->pack, "Acct-Output-Packets", ifreq.stats.p.ppp_opackets);
+ rad_packet_change_int(req->pack, "Acct-Input-Gigawords", req->rpd->acct_input_gigawords);
+ rad_packet_change_int(req->pack, "Acct-Output-Gigawords", req->rpd->acct_output_gigawords);
rad_packet_change_int(req->pack, "Acct-Session-Time", time(NULL) - ppp->start_time);
}
@@ -89,8 +101,11 @@ static void rad_acct_interim_update(struct triton_timer_t *t)
if (rpd->acct_req->timeout.tpd)
return;
- rad_packet_change_val(rpd->acct_req->pack, "Acct-Status-Type", "Interim-Update");
req_set_stat(rpd->acct_req, rpd->ppp);
+ if (!rpd->acct_interim_interval)
+ return;
+
+ rad_packet_change_val(rpd->acct_req->pack, "Acct-Status-Type", "Interim-Update");
req_set_RA(rpd->acct_req, conf_acct_secret);
rad_req_send(rpd->acct_req);
rpd->acct_req->timeout.period = conf_timeout * 1000;
@@ -135,7 +150,7 @@ int rad_acct_start(struct radius_pd_t *rpd)
}
rpd->acct_interim_timer.expire = rad_acct_interim_update;
- rpd->acct_interim_timer.period = rpd->acct_interim_interval * 1000;
+ rpd->acct_interim_timer.period = rpd->acct_interim_interval ? rpd->acct_interim_interval * 1000 : STAT_UPDATE_INTERVAL;
if (rpd->acct_interim_interval && triton_timer_add(rpd->ppp->ctrl->ctx, &rpd->acct_interim_timer, 0)) {
triton_md_unregister_handler(&rpd->acct_req->hnd);
triton_timer_del(&rpd->acct_req->timeout);
diff --git a/accel-pptpd/radius/packet.c b/accel-pptpd/radius/packet.c
index 8623f523..6d22e7a4 100644
--- a/accel-pptpd/radius/packet.c
+++ b/accel-pptpd/radius/packet.c
@@ -231,7 +231,6 @@ void rad_packet_free(struct rad_packet_t *pack)
while(!list_empty(&pack->attrs)) {
attr = list_entry(pack->attrs.next, typeof(*attr), entry);
- log_ppp_debug("free: %s\n", attr->attr->name);
list_del(&attr->entry);
if (attr->attr->type == ATTR_TYPE_STRING || attr->attr->type == ATTR_TYPE_OCTETS)
_free(attr->val.string);
@@ -498,6 +497,12 @@ int rad_packet_change_val(struct rad_packet_t *pack, const char *name, const cha
return 0;
}
+int rad_packet_add_ipaddr(struct rad_packet_t *pack, const char *name, in_addr_t ipaddr)
+{
+ return rad_packet_add_int(pack, name, ipaddr);
+}
+
+
struct rad_attr_t *rad_packet_find_attr(struct rad_packet_t *pack, const char *name)
{
struct rad_attr_t *ra;
diff --git a/accel-pptpd/radius/radius.c b/accel-pptpd/radius/radius.c
index 8a5e7b85..38ace958 100644
--- a/accel-pptpd/radius/radius.c
+++ b/accel-pptpd/radius/radius.c
@@ -5,6 +5,7 @@
#include <unistd.h>
#include <arpa/inet.h>
+#include "mempool.h"
#include "events.h"
#include "log.h"
#include "ppp.h"
@@ -41,6 +42,8 @@ static pthread_rwlock_t sessions_lock = PTHREAD_RWLOCK_INITIALIZER;
static void *pd_key;
static struct ipdb_t ipdb;
+static mempool_t rpd_pool;
+
void rad_proc_attrs(struct rad_req_t *req)
{
struct rad_attr_t *attr;
@@ -104,16 +107,16 @@ static struct ipdb_item_t *get_ip(struct ppp_t *ppp)
static void ppp_starting(struct ppp_t *ppp)
{
- struct radius_pd_t *pd = _malloc(sizeof(*pd));
+ struct radius_pd_t *rpd = mempool_alloc(rpd_pool);
- memset(pd, 0, sizeof(*pd));
- pd->pd.key = &pd_key;
- pd->ppp = ppp;
- pthread_mutex_init(&pd->lock, NULL);
- list_add_tail(&pd->pd.entry, &ppp->pd_list);
+ memset(rpd, 0, sizeof(*rpd));
+ rpd->pd.key = &pd_key;
+ rpd->ppp = ppp;
+ pthread_mutex_init(&rpd->lock, NULL);
+ list_add_tail(&rpd->pd.entry, &ppp->pd_list);
pthread_rwlock_wrlock(&sessions_lock);
- list_add_tail(&pd->entry, &sessions);
+ list_add_tail(&rpd->entry, &sessions);
pthread_rwlock_unlock(&sessions_lock);
}
@@ -147,7 +150,8 @@ static void ppp_finished(struct ppp_t *ppp)
rad_packet_free(rpd->dm_coa_req);
list_del(&rpd->pd.entry);
- _free(rpd);
+
+ mempool_free(rpd);
}
struct radius_pd_t *find_pd(struct ppp_t *ppp)
@@ -166,7 +170,7 @@ struct radius_pd_t *find_pd(struct ppp_t *ppp)
}
-struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, int port_id, in_addr_t ipaddr)
+struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, int port_id, in_addr_t ipaddr, const char *csid)
{
struct radius_pd_t *rpd;
@@ -180,6 +184,8 @@ struct radius_pd_t *rad_find_session(const char *sessionid, const char *username
continue;
if (ipaddr && ipaddr != rpd->ipaddr.peer_addr)
continue;
+ if (csid && rpd->ppp->ctrl->calling_station_id && strcmp(csid, rpd->ppp->ctrl->calling_station_id))
+ continue;
pthread_mutex_lock(&rpd->lock);
pthread_rwlock_unlock(&sessions_lock);
return rpd;
@@ -193,6 +199,7 @@ struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack)
struct rad_attr_t *attr;
const char *sessionid = NULL;
const char *username = NULL;
+ const char *csid = NULL;
int port_id = -1;
in_addr_t ipaddr = 0;
@@ -205,15 +212,17 @@ struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack)
port_id = attr->val.integer;
else if (!strcmp(attr->attr->name, "Framed-IP-Address"))
ipaddr = attr->val.ipaddr;
+ else if (!strcmp(attr->attr->name, "Calling-Station-Id"))
+ csid = attr->val.string;
}
- if (!sessionid && !username && port_id == -1 && ipaddr == 0)
+ if (!sessionid && !username && port_id == -1 && ipaddr == 0 && !csid)
return NULL;
if (username && !sessionid)
return NULL;
- return rad_find_session(sessionid, username, port_id, ipaddr);
+ return rad_find_session(sessionid, username, port_id, ipaddr, csid);
}
int rad_check_nas_pack(struct rad_packet_t *pack)
@@ -275,6 +284,8 @@ static void __init radius_init(void)
{
char *opt;
+ rpd_pool = mempool_create(sizeof(struct radius_pd_t));
+
opt = conf_get_opt("radius", "max-try");
if (opt && atoi(opt) > 0)
conf_max_try = atoi(opt);
diff --git a/accel-pptpd/radius/radius.h b/accel-pptpd/radius/radius.h
index dca93d4f..e202e264 100644
--- a/accel-pptpd/radius/radius.h
+++ b/accel-pptpd/radius/radius.h
@@ -99,6 +99,7 @@ int rad_packet_add_str(struct rad_packet_t *pack, const char *name, const char *
int rad_packet_add_octets(struct rad_packet_t *pack, const char *name, uint8_t *val, int len);
int rad_packet_change_int(struct rad_packet_t *pack, const char *name, int val);
int rad_packet_change_val(struct rad_packet_t *pack, const char *name, const char *val);
+int rad_packet_add_ipaddr(struct rad_packet_t *pack, const char *name, in_addr_t ipaddr);
int rad_packet_add_vendor_octets(struct rad_packet_t *pack, const char *vendor_name, const char *name, const uint8_t *val, int len);
struct rad_attr_t *rad_packet_find_vendor_attr(struct rad_packet_t *pack, const char *vendor_name, const char *name);
diff --git a/accel-pptpd/radius/radius_p.h b/accel-pptpd/radius/radius_p.h
index 3aa54064..ae442238 100644
--- a/accel-pptpd/radius/radius_p.h
+++ b/accel-pptpd/radius/radius_p.h
@@ -18,6 +18,10 @@ struct radius_pd_t
struct rad_req_t *acct_req;
struct triton_timer_t acct_interim_timer;
+ uint32_t acct_input_octets;
+ uint32_t acct_output_octets;
+ uint32_t acct_input_gigawords;
+ uint32_t acct_output_gigawords;
struct rad_packet_t *dm_coa_req;
struct sockaddr_in dm_coa_addr;
@@ -55,7 +59,7 @@ extern int conf_acct_server_port;
extern char *conf_dm_coa_secret;
int rad_check_nas_pack(struct rad_packet_t *pack);
-struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, int port_id, in_addr_t ipaddr);
+struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, int port_id, in_addr_t ipaddr, const char *csid);
struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack);
int rad_dict_load(const char *fname);
diff --git a/accel-pptpd/radius/req.c b/accel-pptpd/radius/req.c
index 6b812f11..cd4a31be 100644
--- a/accel-pptpd/radius/req.c
+++ b/accel-pptpd/radius/req.c
@@ -52,6 +52,9 @@ struct rad_req_t *rad_req_alloc(struct radius_pd_t *rpd, int code, const char *u
if (conf_nas_identifier)
if (rad_packet_add_str(req->pack, "NAS-Identifier", conf_nas_identifier, strlen(conf_nas_identifier)))
goto out_err;
+ if (conf_nas_ip_address)
+ if (rad_packet_add_ipaddr(req->pack, "NAS-IP-Address", inet_addr(conf_nas_ip_address)))
+ goto out_err;
if (rad_packet_add_int(req->pack, "NAS-Port", rpd->ppp->unit_idx))
goto out_err;
if (rad_packet_add_val(req->pack, "NAS-Port-Type", "Virtual"))
@@ -60,6 +63,12 @@ struct rad_req_t *rad_req_alloc(struct radius_pd_t *rpd, int code, const char *u
goto out_err;
if (rad_packet_add_val(req->pack, "Framed-Protocol", "PPP"))
goto out_err;
+ if (rpd->ppp->ctrl->calling_station_id)
+ if (rad_packet_add_str(req->pack, "Calling-Station-Id", rpd->ppp->ctrl->calling_station_id, strlen(rpd->ppp->ctrl->calling_station_id)))
+ goto out_err;
+ if (rpd->ppp->ctrl->called_station_id)
+ if (rad_packet_add_str(req->pack, "Called-Station-Id", rpd->ppp->ctrl->called_station_id, strlen(rpd->ppp->ctrl->called_station_id)))
+ goto out_err;
return req;
@@ -91,6 +100,10 @@ int rad_req_acct_fill(struct rad_req_t *req)
return -1;
if (rad_packet_add_int(req->pack, "Acct-Output-Packets", 0))
return -1;
+ if (rad_packet_add_int(req->pack, "Acct-Input-Gigawords", 0))
+ return -1;
+ if (rad_packet_add_int(req->pack, "Acct-Output-Gigawords", 0))
+ return -1;
return 0;
}